title: Geotools 13 - error writing to MySQL in linux
body: <p>Note: Running geotools 13.0. </p>
  
  <p>I have an application that creates Point shapes.  My application then writes these features in a shapefile and then into MySQL.</p>
  
  <p>When I run the code under Windows, everything works perfect: the data is properly stored in MySQL and I can use it without any trouble.</p>
  
  <p>When I run the code under Linux, shapefiles are created, but the data is not written in MySQL and the following exception is thrown:</p>
  
  <pre><code>WARNING: class org.geotools.filter.function.Collection_NearestFunction has name conflict betwee 'null' and 'Collection_Nearest'
  Exception in thread "main" java.lang.NoSuchFieldError: LINEARIZATION_TOLERANCE
  at org.geotools.jdbc.JDBCFeatureReader.init(JDBCFeatureReader.java:211)
  at org.geotools.jdbc.JDBCFeatureReader.&lt;init&gt;(JDBCFeatureReader.java:137)
  at org.geotools.jdbc.JDBCInsertFeatureWriter.&lt;init&gt;(JDBCInsertFeatureWriter.java:43)
  at org.geotools.jdbc.JDBCFeatureStore.getWriterInternal(JDBCFeatureStore.java:280)
  at org.geotools.data.store.ContentFeatureStore.getWriter(ContentFeatureStore.java:151)
  at org.geotools.data.store.ContentFeatureStore.getWriter(ContentFeatureStore.java:122)
  at org.geotools.data.store.ContentFeatureStore.getWriterAppend(ContentFeatureStore.java:263)
  at org.geotools.data.store.ContentFeatureStore.addFeatures(ContentFeatureStore.java:242)
  at com.technip.projects.gis.GISGenerator.writeShapesMySQL(GISGenerator.java:763)
  at com.technip.projects.gis.GISGenerator.generatePlatforms(GISGenerator.java:416)
  at com.technip.projects.gis.GISGenerator.createShapefiles(GISGenerator.java:249)
  at Machine.run(Machine.java:739)
  at Machine.main(Machine.java:329)
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>private void writeShapesMySQL(List&lt;SimpleFeature&gt; features) throws IOException {
      SimpleFeatureType TYPE = null;
  
      if (!features.isEmpty()) {
          TYPE = features.get(0).getType();
  
          // Drop the table if exists
          try (Connection con = conf.requestConnection("gis")) {
              con.prepareCall("DROP TABLE IF EXISTS " + TYPE.getTypeName() + ";").execute();
          } catch (Exception e) {}
          if (factory == null) {
              initMySQLStore();
          }
  
          SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, features);
  
          gisDS.createSchema(TYPE);
  
          Transaction transaction = new DefaultTransaction("create");
          String      typeName    = null;
  
          for (String s : gisDS.getTypeNames()) {
              if (s.equalsIgnoreCase(TYPE.getTypeName())) {
                  typeName = s;
                  break;
              }
          }
          if (typeName == null) {
              log.error("Cannot find the type " + TYPE.getTypeName() + " in the known types: " + String.valueOf(gisDS.getTypeNames()));
              throw new IOException("Cannot find type " + TYPE.getTypeName() + " -- in other words, developer sucks.");
          }
  
          SimpleFeatureSource featureSource = gisDS.getFeatureSource(typeName);
  
          // System.out.println("SHAPE:"+SHAPE_TYPE);
          if (featureSource instanceof SimpleFeatureStore) {
              SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
  
              featureStore.setTransaction(transaction);
              try {
                  log.info("Adding " + collection.size() + " features into " + TYPE.getTypeName() + " table.");
                  featureStore.addFeatures(collection);
                  transaction.commit();
              } catch (Exception problem) {
                  log.error("Cannot create shapes in MySQL for " + TYPE.getTypeName(), problem);
                  transaction.rollback();
              } finally {
                  transaction.close();
              }
          }
      } else {
          log.warn("Passed empty list to create GIS database.");
      }
  }
  
   private void initMySQLStore() throws IOException {
      factory = new MySQLDataStoreFactory();
  
      Map conMap = new HashMap();
  
      conMap.put("dbtype", "mysql");
      conMap.put("host", conf.getDbserver());
      conMap.put("port", "3306");
      conMap.put("database", "gis");
      conMap.put("user", conf.getDbuser());
      conMap.put("passwd", conf.getDbpass());
  
      gisDS = factory.createDataStore(conMap);
  
      Map&lt;Class&lt;?&gt;, Integer&gt; classMappings = gisDS.getClassToSqlTypeMappings();
  
      classMappings.put(String.class, new Integer(Types.LONGVARCHAR));
  }
  </code></pre>
  
  <p>My first hint is that MySQL is case sensitive in Linux, but not in Windows.  So I checked the created tables both in Linux and Windows, and none of them has a field with such a name (LINEARIZATION_TOLERANCE).</p>
  
  <p>Any hints?</p>
  
  <p>Thanks,</p>
  
  <p>Juan</p>
  
  <p>--UPDATE: PROBLEM SOLVED--</p>
  
  <p>It turned out I had an old .jar from a prior version of geotools in the Linux machine.  Removing all old jars fixed the problem.</p>