United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4628693 Cannot get the new value of the current inserted autoincrement column
JDK-4628693 : Cannot get the new value of the current inserted autoincrement column

Details
Type:
Bug
Submit Date:
2002-01-25
Status:
Resolved
Updated Date:
2002-11-14
Project Name:
JDK
Resolved Date:
2002-11-14
Component:
core-libs
OS:
windows_2000
Sub-Component:
java.sql:bridge
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.2 (mantis)

Related Reports
Relates:

Sub Tasks

Description
###@###.### 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):

    Exception:

    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:

      Exception:

      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


Attachments: 
db1.mdb
Test_InsertRow_Last.java

                                    

Comments
EVALUATION

Bridge definitely have a bug in handling rowpositions after insertRow. Need to fix JdbcOdbcResultSet.java for this.


###@###.### 2002-01-30
                                     
2002-01-30
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.
                                     
2004-06-11
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mantis

FIXED IN:
mantis

INTEGRATED IN:
mantis


                                     
2004-06-14



Hardware and Software, Engineered to Work Together