Inserting geometry using JDBC PreparedStatement
Is there a way to use JDBC PreparedStatements to insert geospatial data? Here's what my prepared statement looks like: PreparedStatement statement = sqlRunner.prepareStatement(insertStatement); statement.setString(1, id); statement.setString(2, feature.getName()); statement.setString(3, feature.getDescription()); statement.setString(4, feature.getType().toString()); statement.setString(5, feature.getGeometry()); statement.executeUpdate(); In this case, feature.getGeometry() returns a string in WKT format. Here's the error I get: EXEC: wrong type for argument 5 of prepared statement: char, expected geometry Thoughts? Thanks, Casey
On 27-05-2013 14:23:54 -0500, Casey Gum wrote:
statement.executeUpdate();
In this case, feature.getGeometry() returns a string in WKT format.
Here's the error I get:
EXEC: wrong type for argument 5 of prepared statement: char, expected geometry
Thoughts?
I'd try to build an SQLData class, like the INET and URL classes in nl.cwi.monetdb.jdbc.types. SQLTypeName probably is geometry, so you can use that for setObject(). Using your implemented UDT, you can build your own TypeMap that has the ("geometry", yourGeometryClass) mapping. This way, getObject() will return a yourGeometryClass instance. Fabian -- Fabian Groffen fabian@monetdb.org column-store pioneer http://www.monetdb.org/Home
participants (2)
-
Casey Gum
-
Fabian Groffen