Icon View Incident Report

Serious Serious
Reported By: Matt Collins
Reported On: 7/8/2009
For: Version 4.28 Build 4
# 3031 Navigating a Result Set Using the Java JDBC/ODBC Bridge Driver Can Cause Invalid Cursor State Error

I am testing the ODBC driver as a possible solution for a project, but I am receiving errors.

The error being thrown is from the "getString" command on the result set:


Exception: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3908)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5702)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:356)0
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:413)
at ExecExtApp.main(ExecExtApp.java:53)


There are also two error windows displayed:

"The exception unknown software exception (0x0eedfade) occurred in the application at location 0x7c812a5b."

"Runtime error 217 at 0006CBCA"

   ResultSet rs;                                   // Data returned from statement queries.
   Connection conn = null;                   // Connection to the database.
   Statement stmtRS;                          // Statements to execute the SQL on the database.
   String url = "jdbc:odbc:CPLocks";     // This is the ODBC datasource setup on the local machine.
   String resgrp = "";

   try {
     // Connect and login to the database.
     conn = DriverManager.getConnection(url, "Admin", "DBAdmin");
     stmtRS = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

     rs = stmtRS.executeQuery("SELECT RES_GRP, RES_ID, SEQ_NO, EXCL_LCK, USR_ID FROM Locks");

     while(rs.next()) {
   resgrp = rs.getString("RES_GRP");


          if (rs.first())

          resgrp = rs.getString("RES_GRP");

            while(rs.next()) {
                  resgrp = rs.getString("RES_GRP");

Comments Comments and Workarounds
There are two issues here, one with the positioning ("Invalid cursor state") and one with the disposal of internal resources in the ODBC Driver.

For the first issue, a workaround is to use an rs.First() call followed by any rs.Next() calls and that should get around this issue. The problem is caused by an absolute positioning error.

For the second issue (AV and runtime error), the problem is that the developer is not closing the statement and connection. You need to do this with the ODBC Driver, otherwise you will leave dangling resources that are attempted to be freed when the ODBC Driver DLL is unloaded, which is not the proper place for this to take place.

Resolution Resolution
Fixed Problem on 7/12/2009 in version 4.28 build 5

Products Affected Products Affected
DBISAM ODBC Client-Server
DBISAM ODBC Client-Server with Source
DBISAM ODBC Standard with Source