How to get the contents field of a spatiallite sqlitejdbc?
I have this code:
statement.executeUpdate("SELECT AddGeometryColumn('areas', 'geom', 4326, 'POLYGON', 'XY')");
//String strSt="INSERT INTO areas VALUES (1, 'zoneA', GeomFromText('POINT(1 1)',4326))";
String strSt="INSERT INTO areas VALUES (1, 'zoneA', GeomFromText('POLYGON (0 0, 10 0, 10 10, 0 10)',4326))";
strSt="select geom from areas where areas.label == 'zoneA'";
and it says that geom field does not exists.
ResultSetMetaData rsmd = rs.getMetaData();
int numColumns = rsmd.getColumnCount();
// Get the column names; column indices start from 1
for (int i=1; i<numColumns+1; i++)
String columnName = rsmd.getColumnName(i);
String str= rsmd.getColumnTypeName(i);
int d= rsmd.getColumnType(i);
columnname is 'geom'
str is null
d is 0
str2 is java.lang.Object
So how to get the value of the field?
Thanks a lot
Re: How to get the contents field of a spatiallite sqlitejdbc?
Add code tags to your post - see the 'BB Code' link below.
It looks like ResultSet doesn't recognise the type of the column. Try using getBytes(String) or getBinaryStream(String) to read the geom field - perhaps you may be able to construct a String from a byte array, if that works? I doubt that will work, though I'd be surprised if those two methods returned nothing. If you're using a special DB-side library, perhaps it has string-coercing functions you can use to produce a readable resultset for Java? I'm guessing at something like "SELECT STRINGIFY(geom)" - where 'STRINGIFY' is either a built-in in your DB, or provided by the spatial data library.
I had a quick search out of curiosity and this page suggests to me that 'asText' might work: