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

Calling updateXXXX methods on ResultSet object causes NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs



      Name: rmT116609 Date: 07/29/2003


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      FULL OS VERSION :
      Microsoft Windows 2000 [5.00.2195]
      The same result with JDK 1.4.0 and 1.4.2

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      The problem persists with MDB file (MS Access database) and MySQL database (when using ODBC!)

      A DESCRIPTION OF THE PROBLEM :
      Use of updateXXX methods on ResultSet object causes NullPointerException at sun.jdbc.odbc.JdbcOdbc* packages... This problem occurs when using JDBC_ODBC bridge. I had the same result with MS Access MDB file and MySQL with ODBC driver.
      When using native driver for MySQL, the problem does not occure. Therefore I think, ODBC bridge has a bug.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create Database in MDB/MySQL
      2. Create ODBC data source "mydata"
      3. Connect to dbURL "jdbc:odbc:mydata"
      4. Create updatable ResultSet (ResultSet.CONCUR_UPDATABLE)
      5. Make a simple querry (SELECT * FROM table1)
      6. Access a row in database (rs.next())
      7. update a value (rs.updateString(1, "NEW"))
      --->U will get this error

      If you use native driver (not the bridge), everything works fine...

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      no Exception thrown
      ACTUAL -
      NullPointerException (no reason for that)

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.NullPointerException
              at sun.jdbc.odbc.JdbcOdbcBoundCol.setRowValues(Unknown Source)
              at sun.jdbc.odbc.JdbcOdbcResultSet.updateBytes(Unknown Source)
              at sun.jdbc.odbc.JdbcOdbcResultSet.updateString(Unknown Source)
              at sun.jdbc.odbc.JdbcOdbcResultSet.updateString(Unknown Source)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      //YOU NEED some ODBC data source and you should change SQL command

      import java.sql.*;
      public class BugReport {

        static Connection conn1() throws Exception
        {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          return DriverManager.getConnection("jdbc:odbc:mydata", "", "");
        }
        static Connection conn2() throws Exception
        {
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          return DriverManager.getConnection("jdbc:mysql:///mydata", "", "");
        }

        public static void main(String args[]) throws Exception
        {
      Connection conn;
      conn = conn1();
      // conn = conn2(); //NOTE: You need MySQL JDBC driver in CLASSPATH

      Statement s = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
      ResultSet rs = s.executeQuery("SELECT * FROM pokus");
      if (!rs.next()) System.exit(0);
      rs.updateObject(2, "NEW DATA " + System.currentTimeMillis());
      rs.updateRow();
      rs.close();
      conn.close();
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      not to use updateXXX methods...
      (Incident Review ID: 192480)
      ======================================================================

            jbrucesunw Jonathan Bruce (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: