[postgis-users] JDBC-Postgis bug

David Garnier david.garnier at etudier-online.com
Wed Jun 18 15:19:13 PDT 2003


Well, first, thanks for using WKB4J! 

Second, the final version of WKB4J will allow you to retrieve integers
along with the byte array representing the geometry, so it might solve
some of you problems. The change is already in the CVS and I'm in the
process of completing the test framework in order to make sure that
everything works fine.

Finally I have a question: are you telling me that it works fine with
your modification but without any other change (like switching to text
cursors) ? At first I didn't used bytea because I thought that it
encoded bytes as String objects and that performance would suffer.

Anyway I gonna try your modification as soon I as possible.

Best Regards,
David Garnier


Le mer 18/06/2003 à 23:56, C F a écrit :
> Hi David,
> I've been messing around a little with your WKB4J application.  It's been 
> working really great, except I had one issue with it.  I actually need to 
> retrieve all associated record data along with the binary geometries.  Since 
> the binary cursor returns all data as binary, I was having a heck of a time 
> converting everything.  I was having some very strange and inconsistant 
> results.... I was in endian hell.  Doing the following for retrieving 
> geometries solved my problems and helped simplify/streamline the process..
> 
> bytea(asbinary(geom_col,'XDR'))
> 
> I modified that one aspect of your WKB4J app and the rest of the app is 
> still running beautifully.  If this is an option for you, it *might* resolve 
> the issues you're having..... I don't know... just thought I'd throw it out 
> there.
> 
> >From: David Garnier <david.garnier at etudier-online.com>
> >Reply-To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> >To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> >Subject: [postgis-users] JDBC-Postgis bug
> >Date: 18 Jun 2003 23:13:05 +0200
> >
> >Hello,
> >
> >I'm still working on my WKB4J project and I've been hitting this bug for
> >some months. I perform a request to Postgis through JDBC, using a binary
> >cursor :
> >
> >             Statement wkbSta = dbConn.createStatement();
> >
> >             wkbSta.execute("begin");
> >             wkbSta.execute(
> >                 "declare wkb_cursor binary cursor for " +
> >completeSQLQuery);
> >             ResultSet wkbRecords =
> >                 wkbSta.executeQuery("fetch forward all in wkb_cursor");
> >
> >             byte[][] fields = new byte[words.length][];
> >
> >             while (wkbRecords.next()) {
> >                 for (int i = 0; i < words.length; i++) {
> >                     fields[i] = wkbRecords.getBytes(words[i]);
> >                 }
> >                 try {
> >-->                  byte[] record = wkbRecords.getBytes("wkb");
> >                 } catch (Exception e) {
> >                     e.printStackTrace();
> >                     log.error(e);
> >                 }
> >             }
> >
> >             wkbSta.execute("close wkb_cursor");
> >             wkbSta.execute("end");
> >             wkbRecords.close();
> >             wkbSta.close();
> >
> >
> >Here is the problem: when I execute this code with the same Connection
> >object, the endian of the result changes after a while. I haven't
> >quantified the effect exactly but it seems to happen on the third or
> >fourth query. For example, for the same record, with a new Connection I
> >would always get the correct result :
> >[1, 6, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0, 0, 8, 0, 0, 0, 116, 3, 0, 0, 31,
> >-53, 118, 82, -58, 92, 99, -64, 82, -18, -62, -81, 92, 51, 3, -64,
> >
> >While with a "used" Connecction, I would get:
> >[0, 0, 0, 0, 6, 0, 0, 0, 1, 0, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 3, 116,
> >-64, 99, 92, -58, 82, 118, -53, 31, -64, 3, 51, 92, -81, -62, -18, 82,
> >
> >According to the OGC documentation, the first byte indicates the byte
> >order (big endian or little endian) and the second array is really the
> >little-endian version of the big-endian (this is actually a mix of
> >bytes, ints and longs so it is not obvious). In my query, I always
> >specify XDR (big endian).
> >
> >This problems is a hard one for me because it would really degrade the
> >performance of the library if I had to reparse the whole array.
> >
> >So, any idea about this problem?
> >
> >Best Regards,
> >
> >--
> >David Garnier <david.garnier at etudier-online.com>
> >
> >
> >_______________________________________________
> >postgis-users mailing list
> >postgis-users at postgis.refractions.net
> >http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> _________________________________________________________________
> Add photos to your messages with MSN 8. Get 2 months FREE*.  
> http://join.msn.com/?page=features/featuredemail
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
-- 
David Garnier <david.garnier at etudier-online.com>




More information about the postgis-users mailing list