-
Bug
-
Resolution: Fixed
-
P2
-
6
-
b59
-
generic
-
generic
-
Verified
JDK : 1.6.0-b53 with jdbc4.jar
DB: ORCL
==========
Testcase:
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
Test Location:
/net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child
How to run:
/net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child/jdbc/docs/Run_Standalone.README
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 if needed.
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.
--------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 SQLException;
@Update(value="insert into eod_update_table (id, firstName, lastName , age) values (200,'valueNewFirst','valueNewLast',200)")
int ValueInsertRow() throws SQLException;
@Query(sql="select * from eod_update_table")
DataSet<eod_update_dataSet> getEodUpdateTable() throws SQLException;
@Query(sql="select * from eod_update_table where firstName={newFirst}")
DataSet<eod_update_dataSet> getNewFirstName(String newFirst) throws SQLException;
}
System.out.println("Start doTest Update001_value_005 Testing" );
System.out.println("Testing value annoation member:");
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.ValueInsertRow();
}catch (SQLException SQLexp) {
System.err.println("TestFailureException: " + SQLexp.getMessage());
SQLexp.printStackTrace();
throw new TestFailureException (this.getClass().getName()+": SQLException caught "+SQLexp.getMessage());
}
System.out.println("Expected number of rows updated is: 1");
if ( returnRows == 1) {
System.out.println("Number of row updated: " + returnRows);
/**
* Verify a new row had been added.
*/
query_all = doTestUpdate001.getEodUpdateTable();
for (eod_update_dataSet c: query_all) {
System.out.println("Query result: id " + c.id + " First name: " + c.firstName +
" Last name: " + c.lastName + " Age: " + c.id);
if ( c.firstName.toString().trim().equals("valueNewFirst") &&
c.lastName.toString().trim().equals("valueNewLast") &&
(c.age == 200) &&
(c.id == 200) ){
System.out.println("The new entry had been found in the DB");
Status = true;
break;
}
else {
System.out.println("ENTRY NOT FOUND in DB!!");
Status = false;
}
}
}
else{
System.out.println("Rows updated " + returnRows );
Status = false;
}
}catch (DBConnectionException DBConnetEx) {
System.err.println(this.getClass().getName()+": DBconnectionException caught "+DBConnetEx.getMessage());
DBConnetEx.printStackTrace();
return Status;
}catch (Exception exp) {
System.err.println("TestFailureException: " + exp.getMessage());
exp.printStackTrace();
throw new TestFailureException (this.getClass().getName()+": Exception caught "+exp.getMessage());
}
return Status;
--------Sample Test/Script END----------------------
Output:
=======
Start Setup Update001_SQL_005
Start doTest Update001_SQL_005 Testing
Testing SQL annoation member:
Checking if the data exist.
Return Rows 0
Adding --> id: 100, First name: SQLnewFirst, Last name: SQLnewLast, Age: 100
Start Cleanup Update001_SQL_005
Update001_SQL_005 Test: FAILED
TestFailureException: null
java.sql.SQLRuntimeException
at com.sun.sql.QueryObjectGeneratorImpl.invoke(Unknown Source)
at $Proxy0.ValueInsertRow(Unknown Source)
at Update001_value_005.doTest(Update001_value_005.java:120)
at Update001_value_005.main(Update001_value_005.java:211)
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(Unknown Source)
... 4 more
TestFailureException: Update001_value_005: SQLRuntimeException caught null
com.sun.j2se_sqe.jdbc.utils.TestFailureException: Update001_value_005: SQLRuntimeException caught null
at Update001_value_005.doTest(Update001_value_005.java:124)
at Update001_value_005.main(Update001_value_005.java:211)
JDBCException: Update001_value_005 : Update001_value_005: Exception caught Update001_value_005: SQLRuntimeException caught null
com.sun.j2se_sqe.jdbc.utils.TestFailureException: Update001_value_005: Exception caught Update001_value_005: SQLRuntimeException caught null
at Update001_value_005.doTest(Update001_value_005.java:162)
at Update001_value_005.main(Update001_value_005.java:211)
Wing,
It would be difficult to access the test over the network, it would be good if you paste the sample program here in the bug description.
Since I could not see the program that cuased this exception, are you using the new parameter mapping scheme as per the spec ? That is using ?1 for the frist param, ?2 for the second param and so on.
Update accordingly.
DB: ORCL
==========
Testcase:
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
Test Location:
/net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child
How to run:
/net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child/jdbc/docs/Run_Standalone.README
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 if needed.
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.
--------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 SQLException;
@Update(value="insert into eod_update_table (id, firstName, lastName , age) values (200,'valueNewFirst','valueNewLast',200)")
int ValueInsertRow() throws SQLException;
@Query(sql="select * from eod_update_table")
DataSet<eod_update_dataSet> getEodUpdateTable() throws SQLException;
@Query(sql="select * from eod_update_table where firstName={newFirst}")
DataSet<eod_update_dataSet> getNewFirstName(String newFirst) throws SQLException;
}
System.out.println("Start doTest Update001_value_005 Testing" );
System.out.println("Testing value annoation member:");
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.ValueInsertRow();
}catch (SQLException SQLexp) {
System.err.println("TestFailureException: " + SQLexp.getMessage());
SQLexp.printStackTrace();
throw new TestFailureException (this.getClass().getName()+": SQLException caught "+SQLexp.getMessage());
}
System.out.println("Expected number of rows updated is: 1");
if ( returnRows == 1) {
System.out.println("Number of row updated: " + returnRows);
/**
* Verify a new row had been added.
*/
query_all = doTestUpdate001.getEodUpdateTable();
for (eod_update_dataSet c: query_all) {
System.out.println("Query result: id " + c.id + " First name: " + c.firstName +
" Last name: " + c.lastName + " Age: " + c.id);
if ( c.firstName.toString().trim().equals("valueNewFirst") &&
c.lastName.toString().trim().equals("valueNewLast") &&
(c.age == 200) &&
(c.id == 200) ){
System.out.println("The new entry had been found in the DB");
Status = true;
break;
}
else {
System.out.println("ENTRY NOT FOUND in DB!!");
Status = false;
}
}
}
else{
System.out.println("Rows updated " + returnRows );
Status = false;
}
}catch (DBConnectionException DBConnetEx) {
System.err.println(this.getClass().getName()+": DBconnectionException caught "+DBConnetEx.getMessage());
DBConnetEx.printStackTrace();
return Status;
}catch (Exception exp) {
System.err.println("TestFailureException: " + exp.getMessage());
exp.printStackTrace();
throw new TestFailureException (this.getClass().getName()+": Exception caught "+exp.getMessage());
}
return Status;
--------Sample Test/Script END----------------------
Output:
=======
Start Setup Update001_SQL_005
Start doTest Update001_SQL_005 Testing
Testing SQL annoation member:
Checking if the data exist.
Return Rows 0
Adding --> id: 100, First name: SQLnewFirst, Last name: SQLnewLast, Age: 100
Start Cleanup Update001_SQL_005
Update001_SQL_005 Test: FAILED
TestFailureException: null
java.sql.SQLRuntimeException
at com.sun.sql.QueryObjectGeneratorImpl.invoke(Unknown Source)
at $Proxy0.ValueInsertRow(Unknown Source)
at Update001_value_005.doTest(Update001_value_005.java:120)
at Update001_value_005.main(Update001_value_005.java:211)
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(Unknown Source)
... 4 more
TestFailureException: Update001_value_005: SQLRuntimeException caught null
com.sun.j2se_sqe.jdbc.utils.TestFailureException: Update001_value_005: SQLRuntimeException caught null
at Update001_value_005.doTest(Update001_value_005.java:124)
at Update001_value_005.main(Update001_value_005.java:211)
JDBCException: Update001_value_005 : Update001_value_005: Exception caught Update001_value_005: SQLRuntimeException caught null
com.sun.j2se_sqe.jdbc.utils.TestFailureException: Update001_value_005: Exception caught Update001_value_005: SQLRuntimeException caught null
at Update001_value_005.doTest(Update001_value_005.java:162)
at Update001_value_005.main(Update001_value_005.java:211)
Wing,
It would be difficult to access the test over the network, it would be good if you paste the sample program here in the bug description.
Since I could not see the program that cuased this exception, are you using the new parameter mapping scheme as per the spec ? That is using ?1 for the frist param, ?2 for the second param and so on.
Update accordingly.