From: Kris Jurka <books@ejurka.com>
To: Dave Held <dave.held@arraysg.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: 8.0 + JDBC3 Driver
Date: Tue, 9 Aug 2005 17:21:32 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0508091712540.28527@leary.csoft.net> (raw)
In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F902618573@asg002.asg.local>
References: <49E94D0CFCD4DB43AFBA928DDD20C8F902618573@asg002.asg.local>
On Tue, 9 Aug 2005, Dave Held wrote:
> First, I have an oddity with the 8.0-310.jdbc3 driver. When I
> query the db, I have to explicity specify the ResultSet type and
> concurrency if I want something other than a FORWARD_ONLY
> ResultSet. This was not necessary in 7.4. How do I tell when a
> table will return a FORWARD_ONLY ResultSet by default?
The javadoc for Connection.prepareStatement says "Result sets created
using the returned PreparedStatement object will by default be type
TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY."
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Connection.html#prepareStatement(java.lang.String)
The 7.4 driver didn't correctly enforce this and let you scroll a forward
only result, but this has been fixed in 8.0.
> Second, I'm having a problem with a query, which I will get to
> in a second. However, I notice from the stack trace that calls
> are being made into the jdbc2 portion of the driver, even though
> I am using the JDBC3 Jar with JDK 1.5. Is this normal, or is there
> something wrong?
This is expected. The JDBC 2 + 3 drivers share source code, so a JDBC 3
build is mostly just a JDBC 2 build plus some extra stuff.
> Third, this is my actual problem:
>
> INSERT INTO my_table
> (my_fields, ...)
> VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> ;
> SELECT currval('my_schema.my_seq')
> ;
>
> I do a prepareStatement() with the above query, I fill in the params,
> and I call executeQuery() hoping to get a ResultSet. However,
> instead I get:
>
> PSQLException: No results were returned by the query.
>
What the driver does is split this query into two pieces and issues them
separately. This returns two results from the server, an update count and
the SELECT result. You should use PreparedStatement.execute() and then
getMoreResults and then getResultSet to navigate to the second part of the
query results.
Kris Jurka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: books@ejurka.com, dave.held@arraysg.com
Subject: Re: 8.0 + JDBC3 Driver
In-Reply-To: <Pine.BSO.4.56.0508091712540.28527@leary.csoft.net>
References: <49E94D0CFCD4DB43AFBA928DDD20C8F902618573@asg002.asg.local> <Pine.BSO.4.56.0508091712540.28527@leary.csoft.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox