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

ArrayIndexOutOfBoundsException when queried 0 rows from the data Base.

XMLWordPrintable

    • b63
    • generic
    • generic
    • Verified

      JDK : 1.6.0 PIT
        Java(TM) 2 Runtime Environment, Standard Edition (build
        1.6.0-internal-sk149173_19_Oct_2005_00_43-b00)
        Java HotSpot(TM) Client VM (build 1.6.0-ea-b56, mixed mode)
      DB : ORCL
      VM : client
      switch/Mode : default
      Platform[s] : Sol 10 sparc and Linux RHAS4

      Test owner :
      Failing Test :
       java_sql_eod/update/Update001_SQL_003 compile_and_execute
       java_sql_eod/update/Update001_value_003 compile_and_execute
       java_sql_eod/update/Update001_SQL_005 compile_and_execute
       java_sql_eod/update/Update001_value_005 compile_and_execute
       java_sql_eod/update/Update001_SQL_006 compile_and_execute
       java_sql_eod/update/Update001_value_006 compile_and_execute
       java_sql_eod/update/Update003_SQL_003 compile_and_execute
       java_sql_eod/update/Update003_value_003 compile_and_execute
       java_sql_eod/update/Update003_SQL_004 compile_and_execute
       java_sql_eod/update/Update003_value_004 compile_and_execute
       java_sql_eod/update/Update003_SQL_005 compile_and_execute
       java_sql_eod/update/Update003_value_005 compile_and_execute


      TestBase Location:
      ==================

          /net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child

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

      Share source location:
      ======================
         /net/cady/export/sqa/tcheung/jdbc/SQE/6.0_child/jdbc/share
         /net/cady/export/sqa/tcheung/jdbc/SQE/6.0_child/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 Update001_SQL_003.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_child/jdbc/Run_Standalone.ksh .

         2) Craete a your testlist.
              echo "java_sql_eod/update/Update001_SQL_005 compile_and_execute" > mytestlist

         3) Overwrite the default environment variables.
             export PIT_HOME=/net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child
             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 ******

      interface IntFacUpdate001 extends BaseQuery {
          @Update(sql="delete from eod_update_table where firstName='Java'")
          int SQLDeleteFirstName() throws SQLRuntimeException ;
          @Update(value="delete from eod_update_table where firstName='Sun'")
          int ValueDeleteFirstName() throws SQLRuntimeException;

          @Select(sql="select * from eod_update_table where firstName=?1")
          DataSet<eod_update_dataSet> getEodUpdateTable(String f_name) throws SQLRuntimeException;

      }

      IntFacUpdate001 doTestUpdate001 = QueryObjectFactory.createDefaultQueryObject(IntFacUpdate001.class, con);
                  try {
                      returnRows = doTestUpdate001.SQLDeleteFirstName();
                  }catch (SQLRuntimeException SQLexp) {
                      System.err.println("TestFailureException: " + SQLexp.getMessage());
                      SQLexp.printStackTrace();
                      throw new TestFailureException (this.getClass().getName()+": SQLRuntimeException caught "+SQLexp.getMessage());
                  }
                  System.out.println("Testing SQL annoation member:");
                  System.out.println("Expected number of deleted row: 1");
                  if ( returnRows == 1) {
                      System.out.println("Number of row deleted: " + returnRows);
                      Status = true;
                      DataSet<eod_update_dataSet> query_all = doTestUpdate001.getEodUpdateTable("Java");
                      if (query_all.size() == 0) {
                          System.out.println("First Name - Java not found in DB as expected.");
                          Status = true;
                      }else{
                          for (eod_update_dataSet c: query_all) {
                              System.out.println("Query the first Name in DB is " + c.firstName);
                              if ( c.firstName.toString().trim().equals("Java")){
                                  Status = false;
                                  break;
                              }
                          }
                      }
                  }
                  else {
                      System.out.println("FAILED: Return " + returnRows);
                      Status = false;
                  }

      =================================
      ::::::::::::::
      eod_update_dataSet.java
      ::::::::::::::
      public class eod_update_dataSet{
          int id;
          String firstName;
          String lastName;
          int age;
      }

      ==========================
      Data in DB.

      #Update001_SQL_003

      setup.ddl.1=create table eod_update_table ( id number, firstName varchar2(32), lastName varchar2(32), age
      int)
      setup.dml.1=insert into eod_update_table values ( 1, 'Sun', 'Java', 39)
      setup.dml.2=insert into eod_update_table values ( 2, 'Java', 'Crazy', 36)
      setup.dml.3=insert into eod_update_table values ( 3, 'Easy', 'Java', 38)


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

      Test output:
      =============
      Start of TEST_PROLOG
      /net/sixnines.sfbay/export/home/amit/wsMustang/build/solaris-sparc
      TEST_ARGS=./orcl
      End of TEST_PROLOG
      Start Setup Update001_SQL_003
      Start doTest Update001_SQL_003 Testing
      Testing SQL annoation member:
      Expected number of deleted row: 1
      Number of row deleted: 1
      TestFailureException: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
      java.sql.SQLRuntimeException: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
              at com.sun.sql.QueryObjectGeneratorImpl.registerDataSet(QueryObjectGeneratorImpl.java:1486)
              at com.sun.sql.QueryObjectGeneratorImpl.getQueryImpl(QueryObjectGeneratorImpl.java:658)
              at com.sun.sql.QueryObjectGeneratorImpl.invoke(QueryObjectGeneratorImpl.java:206)
              at $Proxy0.getEodUpdateTable(Unknown Source)
              at Update001_SQL_003.doTest(Update001_SQL_003.java:120)
              at Update001_SQL_003.main(Update001_SQL_003.java:196)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0 at java.util.Vector.get(Vector.java:708)
              at com.sun.sql.DataSetImpl$DataSetItr.next(DataSetImpl.java:1767)
              at java.util.AbstractList.hashCode(AbstractList.java:528)
              at java.util.HashMap.hash(HashMap.java:271)
              at java.util.WeakHashMap.put(WeakHashMap.java:400)
              at com.sun.sql.QueryObjectGeneratorImpl.registerDataSet(QueryObjectGeneratorImpl.java:1484)
              ... 5 more
      JDBCException: Update001_SQL_003 : Update001_SQL_003: Excepiton caught java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
      com.sun.j2se_sqe.jdbc.utils.TestFailureException: Update001_SQL_003: Excepiton caught java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
              at Update001_SQL_003.doTest(Update001_SQL_003.java:147)
              at Update001_SQL_003.main(Update001_SQL_003.java:196)
      Start Cleanup Update001_SQL_003
      Update001_SQL_003 Test: FAILED



      Specific Machine Info:
      =====================
      For Solaris[sparc/x86] ->
      SunOS orthello 5.10 Generic sun4u sparc SUNW,Ultra-60

      For Linux ->
      [dtftest@inclusion Update001_SQL_003]$ uname -a
      Linux inclusion 2.6.9-16.EL #1 Mon Aug 15 19:58:49 EDT 2005 i686 i686 i386 GNU/Linux

            skaushiksunw Shreyas Kaushik (Inactive)
            tacheung Tak Wing Cheung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: