Consultor Eletrônico



Kbase P36288: JDBC - Invalid Cursor State generated using Resultset.next() method with TYPE_SCROLL-INSENSITIVE or
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/16/2006
Status: Unverified

SYMPTOM(s):

JDBC - Invalid Cursor State generated using Resultset.next() method

SQLState : 24000
Message : [JDBC Progress Driver]:Invalid cursor state.
VendorCode : 0

Using the JDBC 2.0 API ResultSet next() method with TYPE_SCROLL_INSENSITIVE result sets in a while loop.

Using the JDBC 2.0 API ResultSet next() method with TYPE_SCROLL_SENSITIVE result sets in a while loop.

The same loop works fine with TYPE_FORWARD_ONLY result sets.

The Resultset type is TYPE_SCROLL_SENSITIVE:

Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); or


The Resultset type is TYPE_SCROLL_INSENSITIVE:

Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); and


The loop causing the error is:

while (rs.next()) {
System.out.println(rs.getString("State") + " " + rs.getString("State-Name"));
}

CAUSE:

This is a known issue being investigated by Development

FIX:

The following are two possible solutions:

1. EITHER change the Resultset type to CONCUR_READ_ONLY:

Statement stmt = conn.createStatement(ResultSet.CONCUR_READ_ONLY, ResultSet.CONCUR_UPDATABLE);

2. OR modify the while loop to use the Resultset object's absolute() method: int count = 0;
while (rs.next()) {
count++;
rs.absolute(count);
System.out.println(count + " " + rs.getString("State") + " " + rs.getString("StateName"));
}