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

DataSet.delete() & insert() not able to delete/insert rows with DB2/SQLServer.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • core-libs
    • None
    • b78
    • generic
    • generic
    • Verified

      The test is using DataSet.Delete() to delete the first queried row from the database, however, the return value of DataSet.Delete() is false and row didn't remove from the database. It is only in DB2.

      JDK : 1.6.0-b64
      DB : DB2
       driver name : com.sun.sql.jdbc.db2.DB2Driver from DataDirect.
      VM : default
      switch/Mode : default
      Platform[s] : Sol 10 sparc (tried)

      Test owner :
      Failing Test :
          java_sql_eod/query/Query001_012
          java_sql_eod/query/Query001_013

      TestBase Location:
      ==================
          /net/cady/export/sqa/tcheung/jdbc/SQE/6.0

      Test source location:
      =====================
          
      /net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0/jdbc/src/java_sql_eod/query/Query001_012/*.java

      Share source location:
      ======================
         /net/cady/export/sqa/tcheung/jdbc/SQE/6.0/jdbc/share
         /net/cady/export/sqa/tcheung/jdbc/SQE/6.0/share

      tlog file location:
      ==================

      /net/cady.sfbay/export/sqa/tcheung/jdbc/BUGS/[bug id]

      How to reproduce:
      ====================

         1. cd /net/cady.sfbay/export/sqa/tcheung/jdbc/BUGS/[bug id]
         2. ksh Query001_012.tlog [your JDK]

          or

         1) Copy the setup and Run_Standalone.ksh from $TestBase/jdbc to your local dir.
             cp /net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0/jdbc/Run_Standalone.ksh .

         2) Craete a your testlist.
              echo "java_sql_eod/query/Query001_012 compile_and_execute" > mytestlist

         3) Overwrite the default environment variables.
             export PIT_HOME=/net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0
             export TESTLIST = `pwd`/mytestlist
             export JDK_PATH="your jdk"
           if needed.
             export VM_OPTS=""
             export DB_NAME=""
             export DB_DRIVER_NAME=""
             export DB_CONNECTION_NAME=""
             export DB_CONNECTION_STRING=""
             export DB_LOGIN_NAME=""
             export DB_LOGIN_PASSWORD=""

         4) Run_Standalone.ksh.

          Read $TestBase/jdbc/docs/Run_Standalone.README for more detail.

      --------Sample Test/Script START---------------------
      ******* Sample test will not run as standalone java program ******
      try {
                  rows = query.getAllPersons();
              }catch (Exception ex) {
                  utils.closeConnection(con);
                  throw new TestFailureException
                          ("Exception when getting DataSet by executing @Select. [Message="+ex.getMessage()+"]", ex.getCause());
              }
              
              //do some generic checks. common for lot of tests...
              if (null == rows || rows.size() == 0) {
                  System.out.println("Dataset is null/empty : TEST FAILED");
                  utils.closeConnection(con);
                  throw new TestFailureException("Dataset returned by @Select is null/empty.");
              }
              
              int initial_row_size = rows.size();
              System.out.println(this.getClass().getName()+".doTest() : DataSet.size="+initial_row_size);
              
              try {
                  for (PersonDO p : rows) {
                      System.out.println(p.getId() + " " + p.getFirstName());
                      if (p.getId()==1) {
                          if (rows.delete()) {
                              System.out.println(this.getClass().getName()+".doTest() : Calling DataSet.delete )");
                          }
                          else {
                             throw new TestFailureException("rows.delete() returns false" );
                          }
                      }
                  }
              } catch (SQLRuntimeException ex) {
                  System.out.println("Error here :"+ex.getMessage());
                  //if exception was thrown, it is NOT the expected behaviour.
                  System.out.println(this.getClass().getName()+".doTest() : Caught UN-EXPECTED SQLRuntimeException :"+ex.getMessage());
                  System.out.println(this.getClass().getName()+".doTest() : TEST FAILED");
                  //close the connection and return
                  utils.closeConnection(con);
                  throw new TestFailureException("Caught UN-EXPECTED SQLRuntimeException when doing DataSet.delete() :"+ex.getMessage(), ex.getCause());
              }


      interface I_Query001 extends BaseQuery {
          @Select(sql="SELECT * from query001", readOnly=false, connected=true)
          DataSet<PersonDO> getAllPersons();
      }


      --------Sample Test/Script END----------------------

      Test output:
      =============
      /net/koori.sfbay/onestop/jdk/1.6.0/latest/binaries/solaris-sparc
      TEST_ARGS=./db2
      End of TEST_PROLOG
      Query001_012.doTest() : DataSet.size=3
      1 Moises
      TEST FAILED : Query001_012.doTest() :rows.delete() returns false
      com.sun.j2se_sqe.jdbc.utils.TestFailureException: rows.delete() returns false
              at Query001_012.doTest(Query001_012.java:113)
              at Query001_012.main(Query001_012.java:203)


      Specific Machine Info:
      =====================
      For Solaris[sparc/x86] ->
      SunOS orthello 5.10 Generic sun4u sparc SUNW,Ultra-60
      It also failed with DataSet.insert().
      The testcase actually fails under sqlserver as well, so may not be a db2 issue. It passes with oracle.
      Updating synopsis to better reflect bug description.

      Adding tests associated with this bug:

      java_sql_eod/query/Query001_012 compile_and_execute
      java_sql_eod/query/Query001_013 compile_and_execute
      java_sql_eod/query/Query002_016 compile_and_execute
      java_sql_eod/dataset/DataSet004_007 compile_and_execute
      java_sql_eod/dataset/DataSet004_008 compile_and_execute
      java_sql_eod/dataset/DataSet005_001 compile_and_execute
      java_sql_eod/dataset/DataSet005_004 compile_and_execute
      The bug is reproduceable up to build 77. The testcases pass in build 78 with no changes to database or drivers. I am updating this bug to reflect this for our records in case similar issues pop up.

            ssharmasunw Sushmita Sharma (Inactive)
            tacheung Tak Wing Cheung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: