Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Connection createConnection() throws ClassNotFoundException, SQLException {
- Class.forName("org.postgresql.Driver");
- String url = "jdbc:postgresql://localhost:5432/spatialdbnew";
- Connection conn = DriverManager.getConnection(url, "postgres", "postgres"); //use postgres username to skip row-level security to enhance performance
- /*
- * Add the geometry types to the connection.
- */
- ((org.postgresql.PGConnection) conn).addDataType("geometry",
- (Class<? extends PGobject>) Class.forName("org.postgis.PGgeometry"));
- ((org.postgresql.PGConnection) conn).addDataType("box3d",
- (Class<? extends PGobject>) Class.forName("org.postgis.PGbox3d"));
- return conn;
- }
Add Comment
Please, Sign In to add comment