RE: [INTERFACES] JDBC: getUpdateCount always at least one? - Mailing list pgsql-interfaces

From Peter Mount
Subject RE: [INTERFACES] JDBC: getUpdateCount always at least one?
Date
Msg-id 1B3D5E532D18D311861A00600865478C70C22B@exchange1.nt.maidstone.gov.uk
Whole thread Raw
List pgsql-interfaces
This was fixed in time for 6.5.3, but didn't make it into the final cut.

Peter

-- 
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council.



-----Original Message-----
From: Jim Wise [mailto:jwise@draga.com]
Sent: Monday, February 21, 2000 5:29 PM
To: pgsql-interfaces
Subject: [INTERFACES] JDBC: getUpdateCount always at least one?


-----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: "Chandra Wibawa"
Date:
Subject: Fw: Thank for your Clue - PostgreSQL ODBC
Next
From: Peter Mount
Date:
Subject: RE: [INTERFACES] exception running example.basic