Subject Re: ResultSet.next() throws GDS Exception: Cursor Unknown
Author rash_jeanne
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
> > I am testing the FirebirdSQL-1.5.0Beta3 for JDK_1.4 using a
Prepared
> > statement that should return a single record.
> >
> > When I attempt to retrieve the record using ResultSet.next() the
> > following error is thrown:
> >
> > org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569.
> > Dynamic SQL Error SQL error code = -504
> > Cursor unknown
>
> Can you please post your code that you use to fetch data.
>
> Roman

Hi Roman,

I was testing your JDBC driver with an Open Source Persistence Layer
package written by Artyom Rudoy that handles all the direct calls to
the JDBC API. I finally figured out what was happening between the
time the ResultSet is created and the next() method was called. Here
is a simple test case that duplicates the error:

try {
Class.forName("org.firebird.sql.jdbc.FBDriver");
Connection conn = DriverManager.getConnection
("jdbc:firebird:localhost/3050:c:/data/test.fdb","SYSDBA","masterkey")
;
conn.setAutoCommit(false);
PreparedStatement pstmt = conn.prepareStatement("select user_id,
user_nam from UserAccount");
ResultSet rs = pstmt.executeQuery();
conn.commit();
while(rs.next()) {
System.out.println(rs.getString(1)+" "+rs.getString(2));
}
rs.close()
conn.close();
} catch (Exception e) {
e.printStackTrace();
}

The Persistence Layer determines if the JDBC driver supports
transactions and turns off AutoCommit on the connection. It then
calls commit() after each successfull transaction and rollback()
after a failed transaction. It does this with Query transactions as
well. Apparently the commit call to the JDBC driver invalidates the
database cursor.

I am not sure what is the correct way to resolve this problem. For
now I have disabled the transaction processing so that autocommit is
never turned off. Should I modify the Persistence Layer to only call
commit after an Update transaction or should the JDBC driver preserve
the ResultSet after a call to commit()?

Thanks!
Jeanne