On Tue, 20 Jun 2000, Max Khon wrote:
> hi, there!
> try `stmt.executeQuery(...)' instead of `stmt.execute(...)'
Thanks for the suggestion, but the two methods are intended for
different purposes. The former is appropriate when you know in advance
there is exactly one result set produced by the query. The latter is
intended to be used (in the words of the Javadoc documentation) when
working with "an unknown SQL string" which might return zero, one, or
multiple result sets. I need the latter functionality, so
executeQuery() isn't appropriate in this case.
Here's the description of the execute() method and its supporting
methods from Sun's JDBC documentation
7.1.4 Optional or multiple ResultSets
Normally we expect that SQL statements will be executed using either
executeQuery (which returns a single ResultSet) or executeUpdate (which
can be used for any kind of database modification statement and which
returns a count of the rows updated).
However under some circumstances an application may not know whether a
given statement will return a ResultSet until the statement has
executed. In addition, some stored procedures may return several
different ResultSets and/or update counts.
To accommodate these needs we provide a mechanism so that an application
can execute a statement and then process an arbitrary collection of
ResultSets and update counts. This mechanism is based on a fully general
"execute" method, supported by three other methods, getResultSet,
getUpdateCount, and getMoreResults. These methods allow an application
to explore the statement results one at a time and to determine if a
given result was a ResultSet or an update count.
pgsql-interfaces by date
|Next:||From: Constantin Teodorescu||Date: 2000-06-20 17:33:46|
|Subject: Re: pgaccess deletes function in database|
|Previous:||From: Bob Kline||Date: 2000-06-20 10:25:15|
|Subject: getMoreResults() returns false incorrectly |