Guest User

Untitled

a guest
Dec 1st, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public static Connection createConnection() throws ClassNotFoundException, SQLException {
  2. Class.forName("org.postgresql.Driver");
  3. String url = "jdbc:postgresql://localhost:5432/spatialdbnew";
  4. Connection conn = DriverManager.getConnection(url, "postgres", "postgres"); //use postgres username to skip row-level security to enhance performance
  5.  
  6. /*
  7. * Add the geometry types to the connection.
  8. */
  9. ((org.postgresql.PGConnection) conn).addDataType("geometry",
  10. (Class<? extends PGobject>) Class.forName("org.postgis.PGgeometry"));
  11. ((org.postgresql.PGConnection) conn).addDataType("box3d",
  12. (Class<? extends PGobject>) Class.forName("org.postgis.PGbox3d"));
  13.  
  14. return conn;
  15. }
Add Comment
Please, Sign In to add comment