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

CachedRowSet throws NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 5.0
    • core-libs
    • b95
    • x86
    • linux
    • Not verified

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

      ADDITIONAL OS VERSION INFORMATION :
      Linux oxygene 2.6.14-gentoo-r2 #9 PREEMPT Fri Nov 25 16:17:44 NCT 2005 i686 Mobile Intel(R) Pentium(R) 4 - M CPU 2.20GHz GenuineIntel GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Exactly the same description than bug id 5042647, which is considered as fixed since tiger-rc.

      This bug has just been fixed under Windows few hours ago, in the new JVM update. But the same update under Linux does not fix this bug.

      Charles Kolbowicz

      Ref : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042647

      --------------------------
      Extract of the previous report :

      If the data row has columns that have null values, you get a
      NullPointerException. If I change the nulls to values, it works fine.
      Could you give an idea of the process to address this? How long, etc.
       
      Jim Falanga

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use a CachedRowSet selecting rows in a SQL table. When deleting a row with a null field and after the acceptChanges() method call, a NullPointerException is thrown.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Actual deletion of the current row.
      ACTUAL -
      No deletion. And an ugly exception.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Suppression de travaux_ouvrage[id=3117]
      Value of params1 : {0} 3117
      Value of params1 : {0} 2
      Value of params1 : {0} 1
      Value of params1 : {0} 2003-08-26
      Value of params1 : {0} 0.0
      Value of params1 : {0} 0.0
      Value of params1 : {0} 1
      Value of params1 : {0} 1
      Value of params2 : {0} null
      Exception in thread "main" java.lang.NullPointerException
              at com.sun.rowset.internal.CachedRowSetWriter.deleteOriginalRow(CachedRowSetWriter.java:862)
              at com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:312)
              at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:859)
              at testrowset.Main.<init>(Main.java:42)
              at testrowset.Main.main(Main.java:59)
      Java Result: 1

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package testrowset;

      import com.sun.rowset.CachedRowSetImpl;
      import javax.sql.rowset.CachedRowSet;

      public class Main {
          
          /** Creates a new instance of Main */
          public Main() {
              
              CachedRowSet rowset = null;
              String url = "jdbc:postgresql://localhost:5432/koniambo";
              String username = "postgres";
              String password = "postgres";
              String typeName = "travaux_ouvrage";
                      
              try {
                  /*
                   * CachedRowSet initialization
                   */
                  
                  try {
                      Class.forName("org.postgresql.Driver");
                  } catch (ClassNotFoundException cnfe) {
                      cnfe.printStackTrace();
                  }
                  rowset = new CachedRowSetImpl();
                  rowset.setUrl(url);
                  rowset.setUsername(username);
                  rowset.setPassword(password);
                  rowset.setConcurrency(java.sql.ResultSet.CONCUR_UPDATABLE);
                  
                  rowset.setCommand("SELECT * FROM \"" + typeName + "\"");
                  rowset.execute();
                 
                  /*
                   * rowset tuple deletion
                   */
                  rowset.first();
                  System.err.println("Suppression de " + typeName + "[id=" + rowset.getObject(1) + "]");
                  rowset.deleteRow();
                  rowset.acceptChanges();
                                          
              } catch (java.sql.SQLException sqle) {
                  sqle.printStackTrace();
              } finally {
                  try {
                      rowset.close();
                  } catch (java.sql.SQLException sqle) {
                      sqle.printStackTrace();
                  } finally {
                      rowset = null;
                  }
              }
          }
          
          
          public static void main(String[] args) {
              Main main = new Main();
          }
          
      }
      ---------- END SOURCE ----------

            ssharmasunw Sushmita Sharma (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: