SpatialiteSample.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //package com.onemap.overlap.utils;
  2. //
  3. //import java.sql.Connection;
  4. //import java.sql.ResultSet;
  5. //import java.sql.SQLException;
  6. //import java.sql.Statement;
  7. //
  8. //import org.sqlite.SQLiteConfig;
  9. //
  10. //public class SpatialiteSample {
  11. //
  12. //
  13. // public static void main(String[] args) throws ClassNotFoundException, SQLException {
  14. // // load the sqlite-JDBC driver using the current class loader
  15. // Class.forName("org.sqlite.JDBC");
  16. //
  17. // Connection conn = null;
  18. // try {
  19. // // enabling dynamic extension loading
  20. // // absolutely required by SpatiaLite
  21. // System.out.println(org.sqlite.SQLiteJDBCLoader.getVersion());
  22. //// System.setProperty("java.library.path", "E:\\google-download\\mod_spatialite-5.0.1-win-amd64\\mod_spatialite-5.0.1-win-amd64");
  23. // SQLiteConfig config = new SQLiteConfig();
  24. // config.enableLoadExtension(true);
  25. // conn = config.createConnection("jdbc:sqlite:D:\\temp\\mappatchcheck.sqlite");
  26. // // create a database connection
  27. //// conn = DriverManager.getConnection("jdbc:sqlite:spatialite-test.sqlite?enable_load_extension=1"
  28. //// );
  29. //// conn.enableLoadExtension(true);
  30. // Statement stmt = conn.createStatement();
  31. // stmt.setQueryTimeout(30); // set timeout to 30 sec.
  32. //
  33. // // loading SpatiaLite
  34. // stmt.execute("SELECT load_extension('mod_spatialite')");
  35. //
  36. // // checking SQLite and SpatiaLite version + target CPU
  37. // String sql = "SELECT spatialite_version(), spatialite_target_cpu()";
  38. // ResultSet rs = stmt.executeQuery(sql);
  39. // while (rs.next()) {
  40. // // read the result set
  41. // String msg = "SQLite version: ";
  42. // msg += rs.getString(1);
  43. // System.out.println(msg);
  44. // msg = "SpatiaLite version: ";
  45. // msg += rs.getString(2);
  46. // System.out.println(msg);
  47. // }
  48. // // enabling Spatial Metadata
  49. // // this automatically initializes SPATIAL_REF_SYS and GEOMETRY_COLUMNS
  50. //// sql = "SELECT InitSpatialMetadata(1)";
  51. //// stmt.execute(sql);
  52. // } catch (SQLException e) {
  53. // throw new RuntimeException(e);
  54. // }
  55. // }
  56. //}