RE: [INTERFACES] JDBC: getUpdateCount always at least one?

From: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>
To: "'Jim Wise'" <jwise(at)draga(dot)com>, pgsql-interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: RE: [INTERFACES] JDBC: getUpdateCount always at least one?
Date: 2000-02-22 07:26:58
Message-ID: 1B3D5E532D18D311861A00600865478C70C22B@exchange1.nt.maidstone.gov.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)draga(dot)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(at)draga(dot)com

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

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

************

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter Mount 2000-02-22 07:31:12 RE: [INTERFACES] exception running example.basic
Previous Message Dave Del Signore 2000-02-22 03:02:35 CVSup Quick start.