JDK-4628693 : Cannot get the new value of the current inserted autoincrement column
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.sql:bridge
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-01-25
  • Updated: 2002-11-14
  • Resolved: 2002-11-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
1.4.2 mantisFixed
Related Reports
Relates :  
###@###.### 2002-01-25

J2SE Version (please include all output from java -version flag):
 java version "1.4.0-rc"
 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
 Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)

Does this problem occur on J2SE 1.3?  Yes / No (pick one)
 NullPointerExceptions and ArrayIndexOutOfBoundsExceptions exceptions
 throw in the JDBC-ODBC bridge on JDK1.3.1.

Operating System Configuration Information (be specific):
 Windows 2000, Windows NT4

Hardware Configuration Information (be specific):
 P3, 866 Mhz with 512 MB Ram or P2 400Mhz with 256 MB Ram 

Bug Description:
 Cannot get the new value of the current inserted autoincrement column, you
 will get the following 2 exceptions:

 I) Execute "Test_InsertRow_Last" for the first time in an empty database
    table "insertTable", and Invalid cursor state SQLException exception
    throw on method "getObject(1):


    C:\j2sdk1.4.0-rc>c:\j2sdk1.4.0-rc\bin\java Test_InsertRow_Last
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
        at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(JdbcOdbc.java:3211)
        at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(JdbcOdbcResultSet.java:5434)
        at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:571)
        at sun.jdbc.odbc.JdbcOdbcResultSet.getObject(JdbcOdbcResultSet.java:1675)
        at Test_InsertRow_Last.main(Test_InsertRow_Last.java:21)
     MSG: [Microsoft][ODBC Driver Manager] Invalid cursor state

  II) Execute "Test_InsertRow_Last" for the second time after one record had
      been inserted in the table, and invalid cursor position SQLException
      exception throws on ResultSet.last() method:


      C:\j2sdk1.4.0-rc>c:\j2sdk1.4.0-rc\bin\java Test_InsertRow_Last
      java.sql.SQLException: Cursor position (0) is invalid
        at sun.jdbc.odbc.JdbcOdbcResultSet.absolute(JdbcOdbcResultSet.java:2405)
        at sun.jdbc.odbc.JdbcOdbcResultSet.moveToCurrentRow(JdbcOdbcResultSet.java:4176)
        at sun.jdbc.odbc.JdbcOdbcResultSet.last(JdbcOdbcResultSet.java:2222)
        at Test_InsertRow_Last.main(Test_InsertRow_Last.java:20)
      MSG: Cursor position (0) is invalid

Steps to Reproduce (be specific):

1. Create a ODBC DSN called "access" to the attached Access.mdb.
2. Execute Test_InsertRow_Last test program with b91 of JDK 1.4


CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis

WORK AROUND Can not find any workaround, but hope Sun can provide the workaround so they can release their latest HelpDesk 3.0 product with 1.4 and MS Access on March 2002.

EVALUATION Bridge definitely have a bug in handling rowpositions after insertRow. Need to fix JdbcOdbcResultSet.java for this. ###@###.### 2002-01-30