[prev in list] [next in list] [prev in thread] [next in thread]
List: postgis-users
Subject: [postgis-users] Inserting geometries using a JDBC PreparedStatement
From: "Corey Puffalt" <cplists () gmail ! com>
Date: 2006-07-24 17:22:06
Message-ID: ab5847390607241022x6873dd57k840396077462908f () mail ! gmail ! com
[Download RAW message or body]
All...
Has anyone been able to insert geometries using a standard JDBC
PreparedStatement successfully with Postgis 1.1.3 & Postgresql 8.1.4? I had
this working with postgis 0.8 & Postgresql 7.4.1 but I'm now upgrading to
the latest versions.
Here's what I'm attempting to do (stripped down for simplicity...error
handling removed etc.):
==========>8==========
String psqlInsertLine =
"INSERT INTO gis_table (id, attr1, geometry, attr2) " +
"VALUES (?, ?, GeometryFromText(?,4267), ?)";
PreparedStatement insertStmt = conn.prepareStatement(psqlInsertLine);
String geometry = getGeometry(attr1, attr2); // get a geometry based
on the attributes...
insertStmt.setString(1, id);
insertStmt.setString(2, attr1);
insertStmt.setString(3, geometry);
insertStmt.setString(4, attr2);
insertStmt.executeUpdate();
==========8<==========
geometry is a string. For example:
"'LINESTRING(-113.7568111 57.1167611 ,-113.7568111 57.1167611 ,-113.8803611
57.1146194 ,-113.8803611 57.1146194 )'"
This works under 0.8 but with 1.1.3 I'm getting the following error:
org.postgresql.util.PSQLException: ERROR: Invalid OGC WKT (does not start
with P,L,M or G)
As you can see my WKT does, in fact, start with an L ?!?
Does anyone how to get this working? What am I doing wrong?
Thanks,
Corey
[Attachment #3 (text/html)]
All...<br>
<br>
Has anyone been able to insert geometries using a standard JDBC
PreparedStatement successfully with Postgis 1.1.3 & Postgresql
8.1.4? I had this working with postgis 0.8 & Postgresql 7.4.1
but I'm now upgrading to the latest versions.<br>
<br>
Here's what I'm attempting to do (stripped down for simplicity...error handling \
removed etc.):<br> <br>
==========>8==========<br>
String psqlInsertLine =<br>
"INSERT INTO gis_table (id, attr1, geometry, attr2) " +<br>
"VALUES (?, ?, GeometryFromText(?,4267), \
?)";<br>PreparedStatement insertStmt = \
conn.prepareStatement(psqlInsertLine);<br><br>String geometry = getGeometry(attr1, \
attr2); // get a geometry based<br>on the attributes... \
<br><br>insertStmt.setString(1, id);<br>insertStmt.setString(2, \
attr1);<br>insertStmt.setString(3, geometry);<br>insertStmt.setString(4, \
attr2);<br><br>insertStmt.executeUpdate();<br><br>==========8<==========<br> <br>
geometry is a string. For example:<br>
"'LINESTRING(-113.7568111 57.1167611 ,-113.7568111 57.1167611 ,-113.8803611 \
57.1146194 ,-113.8803611 57.1146194 )'"<br> <br>
This works under 0.8 but with 1.1.3 I'm getting the following error:<br>
<br>
org.postgresql.util.PSQLException: ERROR: Invalid OGC WKT (does not start with P,L,M \
or G)<br> <br>
As you can see my WKT does, in fact, start with an L ?!?<br>
<br>
Does anyone how to get this working? What am I doing wrong?<br>
<br>
Thanks,<br>
Corey<br>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic