Subject Re: only one resultset at a time/statement?
Author burghard_w_v_britzke
--- In, "Roman Rokytskyy" <rrokytskyy@a...> wrote:
> > It is prepared statement which is executed immediately before the
> > getResultSet() which raises the exception. so it is not called twice
> > for that executeQuery(). the code is in a large
> > db-framework (, which works with many
> > jdbc-drivers with that code. and it work mainly with the
> > jaybird-jdbc-driver.
> >
> > PreparedStatement stmt = =
> > con.prepareStatement("SELECT ID FROM TABLE...");
> > ...
> > stmt.executeQuery();
> > ResultSet rs = stmt.getResultSet(); // here, the exception is raised
> It is called implicitly inside stmt.executeQuery():
> public ResultSet executeQuery() throws SQLException {
> ...
> return getResultSet();
> }
> You can modify your code to use execute() instead of executeQuery().
> Hmmm... I do not consider it a bug, but if you say that other drivers
> work correctly... Can you check what happens if you call that method
> multiple times for the same result set in other drivers? Do they throw
> exception when the method is called for the second time?
I didn't call it multiple times. The code I listed is definiteley called for the first time in my
application when the exception is raised.
In a company we developed an application with sybase jconnect2 driver where this code is
called thousand times without exception. but I think you are right. In the jdbc api
specification executeQuery() returns a ResultSet and that should be taken immediately. I
will raise a bug for that framework instead. thank you for your help.