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

Updatable ResultSet in jdbc-odbc doesn't work in 1.4 beta3

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • core-libs



      Name: rmT116609 Date: 12/03/2001


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


      --- Test2.java
      import java.sql.*;
      import java.util.*;

      public class Test2
      {
       static void dump(byte[] buf)
       {
        for(int i=0; i<buf.length; i++)
          {
           int v = buf[i] & 0xff;
           System.out.print( Character.forDigit(v >> 4,16) );
           System.out.print( Character.forDigit(v & 0xf,16) );
          }

        System.out.println();
       }

       static void showTable(Statement stmt) throws Exception
       {
        ResultSet rs = stmt.executeQuery("SELECT Val FROM Test");

        while( rs.next() )
          {
           dump( rs.getBytes(1) );
          }

        rs.close();
       }

       static void tryUpdateString(Connection db) throws Exception
       {
        Statement rsstmt = db.createStatement
          (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);


        ResultSet rs = rsstmt.executeQuery("SELECT Val FROM Test");

        rs.first();
        rs.updateString(1,"DEF");

        rs.updateRow();

        rs.next();
        rs.updateString(1,"\u0413\u0414\u0415");

        rs.updateRow();
        rs.close();
        rsstmt.close();
       }

       static void tryUpdateBytes(Connection db) throws Exception
       {
        Statement rsstmt = db.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);


        ResultSet rs = rsstmt.executeQuery("SELECT Val FROM Test");

        rs.first();
        rs.updateBytes(1,"DEF".getBytes());

        rs.updateRow();

        rs.next();
        rs.updateBytes(1,"\u0413\u0414\u0415".getBytes("Cp1251"));

        rs.updateRow();
        rs.close();
        rsstmt.close();
       }

       public static void main(String[] args) throws Exception
       {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        Properties connInfo = new Properties();

        connInfo.put("charSet","Cp1251");

        Connection db = DriverManager.getConnection("jdbc:odbc:test", connInfo);

        DatabaseMetaData dbmeta = db.getMetaData();

        System.out.println("Database: "+dbmeta.getDatabaseProductName()+ ", ver. "+dbmeta.getDatabaseProductVersion());

        System.out.println("Driver: "+dbmeta.getDriverName()+ ", ver. "+dbmeta.getDriverVersion());


        Statement stmt = db.createStatement();

        try
          {
           stmt.executeUpdate("DROP TABLE Test");
          }
        catch (Exception ignore) {}

        stmt.executeUpdate("CREATE TABLE Test (Val VARCHAR(10))");
        stmt.executeUpdate("INSERT INTO Test (Val) VALUES ('ABC')");
        stmt.executeUpdate("INSERT INTO Test (Val) VALUES ('\u0410\u0411\u0412')");

        showTable(stmt);

        if( args.length==0 )
          {
           tryUpdateString(db);
           showTable(stmt);
          }
        else
          {
           tryUpdateBytes(db);
           showTable(stmt);
          }

        db.close();
       }
      }
      ---

      Create new database with MS Access 97, and execute this.

      >java Test2
      Database: ACCESS, ver. 03.50.0000
      Driver: JDBC-ODBC Bridge (ODBCJT32.DLL), ver. 2.0001 (04.00.6019)
      414243
      c0c1c2

      An unexpected exception has been detected in native code outside the VM.
      Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x7800D0C8
      Function=[Unknown.]
      Library=(N/A)

      NOTE: We are unable to locate the function name symbol for the error
            just occurred. Please refer to release documentation for possible
            reason and solutions.


      Current Java thread:
      at sun.jdbc.odbc.JdbcOdbc.ReleaseStoredBytes(Native Method)
      at sun.jdbc.odbc.JdbcOdbcResultSet.FreeCols(JdbcOdbcResultSet.java:1514)
      - locked <028237B0> (a sun.jdbc.odbc.JdbcOdbcResultSet)
      at sun.jdbc.odbc.JdbcOdbcResultSet.updateRow
      (JdbcOdbcResultSet.java:4055)
      at Test2.tryUpdateString(Test2.java:47)
      at Test2.main(Test2.java:108)

      Dynamic libraries:
      0x7D6F0000 - 0x7D70D000 C:\WINDOWS\SYSTEM\IMAGEHLP.DLL

      Local Time = Mon Nov 12 02:19:38 2001
      Elapsed Time = 7
      #
      # The exception above was detected in native code outside the VM
      #
      # Java VM: Java HotSpot(TM) Client VM (1.4.0-beta3-b84 mixed mode)
      #
      # An error report file has been saved as hs_err_pid4294516309.log.
      # Please refer to the file for further information.
      #

      >java Test2 1

      Database: ACCESS, ver. 03.50.0000
      Driver: JDBC-ODBC Bridge (ODBCJT32.DLL), ver. 2.0001 (04.00.6019)
      414243
      c0c1c2

      An unexpected exception has been detected in native code outside the VM.
      Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x7800D0C8
      Function=[Unknown.]
      Library=(N/A)

      NOTE: We are unable to locate the function name symbol for the error
            just occurred. Please refer to release documentation for possible
            reason and solutions.


      Current Java thread:
      at sun.jdbc.odbc.JdbcOdbc.ReleaseStoredBytes(Native Method)
      at sun.jdbc.odbc.JdbcOdbcResultSet.FreeCols(JdbcOdbcResultSet.java:1514)
      - locked <028237B0> (a sun.jdbc.odbc.JdbcOdbcResultSet)
      at sun.jdbc.odbc.JdbcOdbcResultSet.updateRow
      (JdbcOdbcResultSet.java:4055)
      at Test2.tryUpdateBytes(Test2.java:68)
      at Test2.main(Test2.java:113)

      Dynamic libraries:
      0x7D6F0000 - 0x7D70D000 C:\WINDOWS\SYSTEM\IMAGEHLP.DLL

      Local Time = Mon Nov 12 02:20:29 2001
      Elapsed Time = 2
      #
      # The exception above was detected in native code outside the VM
      #
      # Java VM: Java HotSpot(TM) Client VM (1.4.0-beta3-b84 mixed mode)
      #
      # An error report file has been saved as hs_err_pid4294550101.log.
      # Please refer to the file for further information.
      #

      If updating only one row instead two, then updateRow() isn't crashed JVM, but
      do not updating database.
      (Review ID: 135437)
      ======================================================================

            bpg Binod Pankajakshy Gangadharan (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: