JDBC: getUpdateCount always at least one? - Mailing list pgsql-interfaces

From Jim Wise
Subject JDBC: getUpdateCount always at least one?
Date
Msg-id Pine.NEB.4.21.0002211217170.10855-100000@himring.draga.com
Whole thread Raw
List pgsql-interfaces
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I am writing a program which uses the Statement.execute() method to
execute arbitrary SQL statements, and uses ResultSetMetaData to parse
the resulting result set.  Now, when Statement.execute() returns false,
it means that there is no result set, but that Statement.getUpdateCount()
can be used to get a count of how many rows were affected by the SQL
statement.  In the update, insert and delete cases this works fine, but
I've found that when passing in a null query, or a query whose WHERE
clause prevents it from affecting any rows, getUpdateCount is still
returning 1.

This is with the version of the JDBC driver which shipped with 6.5.3,
under JDK 1.1.8.

Is this normal, is it a know problem, or is it something I'm doing
wrong?  The code in question looks basically like this:
private void doRequest (String req){           try {               java.sql.Statement s = conn.createStatement();[...]
    if(s.execute(req))               {
[...]
    } else {                       rowsTouched = s.getUpdateCount();               }    } catch (Exception e) {
     out.println("<PRE>");               e.printStackTrace(out);               out.println("</PRE>");           }}
 

- --             Jim Wise            jwise@draga.com

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/AwUBOLF13i2NgFbJL33VEQJ/wQCgycyF7I7nLNTiSx7GAgvEZ08D2/YAn0mY
G3eBRIpdqcwENIvq4xfntHEc
=Z7GV
-----END PGP SIGNATURE-----



pgsql-interfaces by date:

Previous
From: richard clark
Date:
Subject: SUBSCRIBE
Next
From: richard clark
Date:
Subject: subscribe