Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4410284

Updatable result sets do not work with JDBC-ODBC Bridge

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • core-libs
    • beta
    • x86
    • windows_98, windows_2000



      Name: boT120536 Date: 01/31/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      I want to use the updateXXX methods of JDBC 2.0 to update and insert rows in my
      Microsft SQL Server and Microsoft Access databases using the JDBC-ODBC Bridge.
      The JDBC documentation section 9.4 states that the Bridge supports updatable
      result sets.

      For this test program, databases have a table Test, containing a single column
      of type int(4), which is defined as the primary key, and a single row with
      value 23. The purpose of the test program is to update the value to 14. Here is
      the source code:

      import java.sql.*;

      public class Test
      {
      public static void main( String[] args ) throws SQLException
      {
      new sun.jdbc.odbc.JdbcOdbcDriver();
      Connection connection = DriverManager.getConnection(
      "jdbc:odbc:MS Access Database;DBQ=mydata.mdb" );
      Statement statement = connection.createStatement(
      ResultSet.TYPE_SCROLL_SENSITIVE,
      ResultSet.CONCUR_UPDATABLE );
      ResultSet data = statement.executeQuery( "SELECT * FROM Test" );
      System.out.println( data.getConcurrency() );
      System.out.println( data.getType() );
      data.next();
      System.out.println( data.getInt( 1 ) );
      data.updateInt( 1, 14 );
      data.updateRow();
      System.out.println( data.getInt( 1 ) );
      connection.close();
      }
      }

      When compiled and run the output is:

      1008
      1005
      23
      0

      The 1008 and 1005 are as expected, indicating the result set should be
      updatable. However, the data value has been updated to 0, not 14 as expected.

      If I try to do an insert by adding data.moveToInsertRow() and changing
      data.updateRow() to data.insertRow() I get an exception:

      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
          at sun.jdbc.odbc.JdbcOdbcResultSet.bindCol(JdbcOdbcResultSet.java:4485)
          at sun.jdbc.odbc.JdbcOdbcResultSet.insertRow(JdbcOdbcResultSet.java:3941)
          at Test.main(Test.java:20)

      I have tried using all three result set scroll types: TYPE_SCROLL_INSENSITIVE
      produces a feature not supported exception from Microsoft's ODBC driver.
      TYPE_FORWARD_ONLY behaves the same as TYPE_SENSITIVE above.
      (Review ID: 115669)
      ======================================================================

            jbrucesunw Jonathan Bruce (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: