Revision: 4633
          http://sourceforge.net/p/jump-pilot/code/4633
Author:   elnico
Date:     2015-12-18 13:33:15 +0000 (Fri, 18 Dec 2015)
Log Message:
-----------
Log if spatialite extension is loaded or not.
Protection for spatial databases connection that do not support a second extent 
query:
  query is not run to avoid conversion type errors: SQLite w/o Spatialite is 
now correctly handled

Modified Paths:
--------------
    
core/trunk/src/com/vividsolutions/jump/datastore/spatialdatabases/SpatialDatabasesDSMetadata.java
    
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteDSMetadata.java

Modified: 
core/trunk/src/com/vividsolutions/jump/datastore/spatialdatabases/SpatialDatabasesDSMetadata.java
===================================================================
--- 
core/trunk/src/com/vividsolutions/jump/datastore/spatialdatabases/SpatialDatabasesDSMetadata.java
   2015-12-18 11:09:11 UTC (rev 4632)
+++ 
core/trunk/src/com/vividsolutions/jump/datastore/spatialdatabases/SpatialDatabasesDSMetadata.java
   2015-12-18 13:33:15 UTC (rev 4633)
@@ -263,7 +263,11 @@
       // If attributeName is indexed but indexed has not been initialized
       // (no VACUUM ANALYZE) ST_Estimated_Extent may throw an exception.
       // In this case, try the second method using ST_Extent
-      JDBCUtil.execute(conn.getConnection(), sql2, resultSetBlock);
+      if (sql2 != null) {
+        // some drivers do not support a second SQL query for extent:
+        /// sqlite w/o spatialite for instance
+        JDBCUtil.execute(conn.getConnection(), sql2, resultSetBlock);
+      }
     }
     //System.out.println("getting extent for: " + datasetName + "." + 
attributeName + ": " + e[0].toString()  + " in th: " + 
Thread.currentThread().getName());
     return e[0];

Modified: 
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteDSMetadata.java
===================================================================
--- 
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteDSMetadata.java
       2015-12-18 11:09:11 UTC (rev 4632)
+++ 
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteDSMetadata.java
       2015-12-18 13:33:15 UTC (rev 4633)
@@ -4,6 +4,7 @@
 import com.vividsolutions.jump.datastore.spatialdatabases.*;
 import com.vividsolutions.jump.datastore.jdbc.JDBCUtil;
 import com.vividsolutions.jump.datastore.jdbc.ResultSetBlock;
+import com.vividsolutions.jump.workbench.JUMPWorkbench;
 import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -61,7 +62,8 @@
     defaultSchemaName = "";
     spatialDbName = isSpatialiteLoaded() ? "Spatialite" : "SQLite";
     spatialExtentQuery1 = "SELECT %s from %s";
-    spatialExtentQuery2 = "SELECT %s from %s";
+    // no second query for spatialite
+    spatialExtentQuery2 = null;
     sridQuery = "SELECT srid FROM geometry_columns where f_table_name = '%s' 
and f_geometry_column = '%s'";
     // geo column query needs to be built occording to geometryColumnsLayout
     if (this.geometryColumnsLayout == GeometryColumnsLayout.FDO_LAYOUT) {
@@ -82,7 +84,6 @@
     // must cast the geometric field according to its type, to be able to use 
spatialite functions.
     //return String.format(spatialExtentQuery1, attributeName, table);
     String ret = "select 1";
-    
 
     GeometricColumnType gcType = this.geoColTypesdMap.get(table.toLowerCase() 
+ "." + attributeName.toLowerCase());
 
@@ -112,8 +113,7 @@
 
   @Override
   public String getSpatialExtentQuery2(String schema, String table, String 
attributeName) {
-    // only one mechanism to get extent from spatialite
-    return getSpatialExtentQuery1(schema, table, attributeName);
+    return spatialExtentQuery2;
   }
 
   /**
@@ -145,10 +145,14 @@
       ResultSet rs = stmt.executeQuery("select spatialite_version()");
       rs.next();
       this.setSpatialiteVersion(rs.getString(1));
-      //TODO: log
-      System.out.println("SpatialDatabasesPlugin: Spatialite extension loaded 
for this connexion, version: " + this.getSpatialiteVersion());
+      
+      JUMPWorkbench.getInstance().getFrame().log(
+              "SpatialDatabasesPlugin: Spatialite extension loaded for this 
connexion, version: " 
+                  + this.getSpatialiteVersion(), this.getClass());
     } catch (Exception e) {
-      System.out.println("SpatialDatabasesPlugin: Cannot load Spatialite 
Extention (mod_spatialite), reason:" + e.getMessage());
+      JUMPWorkbench.getInstance().getFrame().log(
+              "SpatialDatabasesPlugin: CANNOT load Spatialite Extention 
(mod_spatialite), reason:" 
+                  + e.getMessage(), this.getClass());
     } finally {
       try {
         stmt.close();


------------------------------------------------------------------------------
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to