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

CachedRowSetImpl.acceptChanges throws error when DATE column has NULLs

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u25
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_8

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_25"


      ADDITIONAL OS VERSION INFORMATION :
      Windows 8.1 Pro 64-bit (6.3.9600)

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Oracle 11g Express Edition 64-bit

      A DESCRIPTION OF THE PROBLEM :
      com.sun.rowset.CachedRowSetImpl (and WebRowSetImpl too) 's acceptChanges() method throws an error "ORA-00932: inconsistent datatypes: expected DATE got NUMBER" when SQL command contains DATE column and at least one row in result set has original DATE column value 'NULL'

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Create test tables in Oracle database with script:

      CREATE TABLE TABLE1 (
        ID NUMBER(10) NOT NULL PRIMARY KEY,
        QTY NUMBER(10),
        DT DATE
      );

      INSERT INTO TABLE1 (ID, QTY, DT) VALUES (1, 10, SYSDATE);
      INSERT INTO TABLE1 (ID, QTY, DT) VALUES (2, 20, NULL);
      INSERT INTO TABLE1 (ID, QTY, DT) VALUES (3, 30, SYSDATE);

      2) Save the source java code (below)to file CRSTest1Main.java
      3) Correct connection url, compile and run


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All three rows should get their 'QTY' field incremented, and "Succeeded!" should appear at console screen
      ACTUAL -
      Only rows with DT != NULL get their 'QTY' field incremented (1-st and 3-rd), and exception "SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected DATE got NUMBER" appears

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected DATE got NUMBER

      at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:1002)
      at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:898)
      at oracle.jdbc.driver.T2CPreparedStatement.executeForDescribe(T2CPreparedStatement.java:686)
      at oracle.jdbc.driver.T2CPreparedStatement.executeForRows(T2CPreparedStatement.java:942)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1150)
      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4798)
      at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:4875)
      at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1361)
      at com.sun.rowset.internal.CachedRowSetWriter.updateOriginalRow(CachedRowSetWriter.java:766)
      at com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:362)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:881)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:944)
      at CRSTest1Main.main(CRSTest1Main.java:30)
      javax.sql.rowset.spi.SyncProviderException: 3conflicts while synchronizing
      at com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:413)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:881)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:944)
      at CRSTest1Main.main(CRSTest1Main.java:30)
      3conflicts while synchronizing


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.sql.*;
      import javax.sql.rowset.*;
      import com.sun.rowset.CachedRowSetImpl;

      public class CRSTest1Main {

      public static void main(String[] args) {

      try {
      Connection con1 = null;
      try {
      con1 = DriverManager.getConnection("jdbc:oracle:oci8:test/test@//localhost:1521/xe");
      con1.setAutoCommit(false);
      CachedRowSet crs1 = null;
      try {
      crs1 = new CachedRowSetImpl();
      crs1.setCommand("SELECT t.* FROM TABLE1 t");
      crs1.setTableName("TABLE1");
      // int [] keys = {1};
      // crs1.setKeyColumns(keys);
      crs1.execute(con1);

      while (crs1.next()) {
      crs1.updateInt("QTY", crs1.getInt("QTY") + 1);
      crs1.updateRow();
      }
      crs1.acceptChanges(con1);
      }
      finally {
      if (crs1 != null) crs1.close();
      }
      }
      finally {
      if (con1 != null) con1.close();
      }
      System.out.println("Succeeded!");
      } catch (SQLException e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      }
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Not found

        Attachments

          Activity

            People

            • Assignee:
              lancea Lance Andersen
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: