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

@Update with insert sql statement will throw a java.lang.NumberFormatException:

XMLWordPrintable

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

      The test is trying to add a row into a database using the following, but failed with an exception.

      @Update(sql="insert into eod_update_table (id, firstName, lastName , age) values (100,'SQLnewFirst','SQLnewLast',100)")
      int SQLInsertRow() throws SQLRuntimeException;


      JDK : 1.6.0-b68
      DB : ORCL
      VM : default
      switch/Mode : default
      Platform[s] : Sol 9 and 10 sparc and x86

      Test owner :
      Failing Test :
          java_sql_eod/update/Update001_SQL_005
          java_sql_eod/update/Update001_value_005
          java_sql_eod/update/Update003_SQL_004
          java_sql_eod/update/Update003_value_004
          java_sql_eod/update/Update003_SQL_005
           java_sql_eod/update/Update003_value_005


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

          /net/cady.sfbay/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/update/Update001_SQL_005/*.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 Update001_SQL_005.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/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
             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="insert into eod_update_table (id, firstName, lastName , age) values (100,'SQLnewFirst','SQLnewLast',100)")
          int SQLInsertRow() throws SQLRuntimeException;

          @Update(value="insert into eod_update_table (id, firstName, lastName , age) values (200,'valueNewFirst','valueNewLast',200)")
          int ValueInsertRow() throws SQLRuntimeException;
          
          @Select(sql="select * from eod_update_table")
          DataSet<eod_update_dataSet> getEodUpdateTable() throws SQLRuntimeException;
          
          @Select(sql="select * from eod_update_table where firstName=?1")
          DataSet<eod_update_dataSet> getNewFirstName(String newFirst) throws SQLRuntimeException;
          
      }

       try {
                  Connection con = utils.getJDBC3Connection();
                  //IntFacUpdate001 doTestUpdate001 = con.createQueryObject(IntFacUpdate001.class);
                  IntFacUpdate001 doTestUpdate001 = QueryObjectFactory.createDefaultQueryObject(IntFacUpdate001.class, con);
                  
                  DataSet<eod_update_dataSet> query_all = doTestUpdate001.getNewFirstName("SQLnewFirst");
                  System.out.println("Checking if the data exist.");
                  System.out.println("Return Rows " + query_all.size());
                  if ( query_all.size() != 0 ) {
                      throw new TestFailureException("Data exist in DataBase.");
                  }
                  
                  System.out.println("Adding --> id: 100, First name: SQLnewFirst, Last name: SQLnewLast, Age: 100");
                  try{
                      returnRows = doTestUpdate001.SQLInsertRow();
                  }catch (SQLRuntimeException SQLexp) {
                      System.err.println("TestFailureException: " + SQLexp.getMessage());
                      SQLexp.printStackTrace();
                      throw new TestFailureException (this.getClass().getName()+": SQLRuntimeException caught "+SQLexp.getMessage());
                  }


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

      Test output:
      =============
      TestFailureException: java.lang.NumberFormatException: For input string: "n"
      java.sql.SQLRuntimeException: java.lang.NumberFormatException: For input string: "n" at com.sun.sql.QueryObjectGeneratorImpl.invoke(QueryObjectGeneratorImpl.java:219)
              at $Proxy0.SQLInsertRow(Unknown Source)
              at Update001_SQL_005.doTest(Update001_SQL_005.java:120)
              at Update001_SQL_005.main(Update001_SQL_005.java:210)
      Caused by: java.lang.NumberFormatException: For input string: "n"
              at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
              at java.lang.Integer.parseInt(Integer.java:447)
              at java.lang.Integer.parseInt(Integer.java:497)
              at com.sun.sql.QueryObjectGeneratorImpl.getUpdateImpl(QueryObjectGeneratorImpl.java:429)
              at com.sun.sql.QueryObjectGeneratorImpl.invoke(QueryObjectGeneratorImpl.java:211)
              ... 3 more
      TestFailureException: Update001_SQL_005: SQLRuntimeException caught java.lang.NumberFormatException: For input string: "n"
      com.sun.j2se_sqe.jdbc.utils.TestFailureException: Update001_SQL_005: SQLRuntimeException caught java.lang.NumberFormatException: For input string: "n"
              at Update001_SQL_005.doTest(Update001_SQL_005.java:124)
              at Update001_SQL_005.main(Update001_SQL_005.java:210)
      JDBCException: Update001_SQL_005 : Update001_SQL_005: Exception caught Update001_SQL_005: SQLRuntimeException caught java.lang.NumberFormatException: For input string:
      "n"
      com.sun.j2se_sqe.jdbc.utils.TestFailureException: Update001_SQL_005: Exception caught Update001_SQL_005: SQLRuntimeException caught java.lang.NumberFormatException: For input string: "n"
              at Update001_SQL_005.doTest(Update001_SQL_005.java:161)
              at Update001_SQL_005.main(Update001_SQL_005.java:210)

      Specific Machine Info:
      =====================
      For Solaris[sparc/x86] ->
      SunOS orthello 5.10 Generic sun4u sparc SUNW,Ultra-60
      I am correcting original bug description which says it is failing in 1.6.0-b86 to correct value of 1.6.0-b68. The failing tests are reproducible until b77. They are now passing in b78.

      Providing the associated tests:
      java_sql_eod/update/Update001_SQL_005 compile_and_execute
      java_sql_eod/update/Update001_value_005 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

            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: