Hey Jody, I'm looking to do prepared statements in PostGIS, but have a couple questions.

It looks like you just call:

String sql = makeInsertSql(current);
statement = conn.prepareStatement( sql );

Just to confirm, the docs seem to say that you don't need to have '?' things in your sql statement, so basically this code says to me that you just use the SQL statement with values, but since you're using the compiled statement it will it ignore them. Is that right?

Second, this doInsert is just called on one feature, so it doesn't appear to me to gain any of the supposed big win of using prepared statements: 'Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed.'

This seems to imply to me that if you call prepareStatement each time, then it has to create a new one. That we'd get the pre-compilation if we had addFeatures(features) prepare the statement, and then each doInsert would use that same prepared statement...

Or is the system smart about caching the prepared statements, and it calls them if they've already been compiled?

Or have you not tested when trying to insert a number of features in one insert statement?

Chris

Jody Garnett wrote:
Um dave the method was from OracleFeatureWrtier (well actually JDBCFeatureWriter) and was the original horrible hack left over from the DataSource api.

I have updated it to use prepared statements, SDO class still I have added the dependency on JTS1.7, but still need to pick up jtsio dependency.

Jody

That method will take care of it for you, notice MultiLineString is a subclass of Geometry :) Cheers, David

On 3/14/06, *Oliver Loe* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Hi

    I'm trying to encode MultiLineString geometries to be inserted
    into oracle. I found this method in SQLEncodeOracle:

    public static String toSDOGeom(Geometry geometry, int srid) {
            if (Point.class.isAssignableFrom(geometry.getClass())) {
                return toSDOGeom((Point) geometry, srid);
            } else if
    (LineString.class.isAssignableFrom(geometry.getClass())) {
                return toSDOGeom((LineString) geometry, srid);
            } else if
    (Polygon.class.isAssignableFrom(geometry.getClass())) {
                return toSDOGeom((Polygon) geometry, srid);
            } else {
                LOGGER.warning("Got a literal geometry that I can't
    handle: "
                    + geometry.getClass().getName());

                return "";
            }
        }

    It does not cater for MultiLineString objects. How can I get
    around this? Is there a fix for it?
Oliver






-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

--
Chris Holmes
The Open Planning Project
thoughts at: http://cholmes.wordpress.com
begin:vcard
fn:Chris Holmes
n:Holmes;Chris
org:The Open Planning Project
adr:;;377 Broadway, 11th Floor;New York;NY;10013;USA
email;internet:[EMAIL PROTECTED]
title:VP, Strategic Development
x-mozilla-html:FALSE
url:http://topp.openplans.org
version:2.1
end:vcard

Reply via email to