Java Tester [message #295173] |
Mon, 21 January 2008 10:50 |
desiaashik
Messages: 1 Registered: January 2008
|
Junior Member |
|
|
Hi,
I am running an automated test in Selenium with Java programming. When I try to do DB checking, I get Exhausted resultset exception. Does anyone have any suggestions for this? I am pasting error and DB test code.
ERROR:
Select emailaddress, websiteid, regcomplete from members where emailaddress = 'kunal_121@eversave.com' AND websiteid='1276' AND regcomplete =-1
java.sql.SQLException: Exhausted Resultset
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:119)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:115)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:221)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:293)
false
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:574)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:2128)
at eversave.methods.DatabaseTest.checkOffers(DatabaseTest.java:54)
at eversave.tests.Offers.offers_execute_test(Offers.java:104)
at eversave.tests.Offers.offers_test_005(Offers.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:478)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:607)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:874)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.runWorkers(TestRunner.java:689)
at org.testng.TestRunner.privateRun(TestRunner.java:566)
at org.testng.TestRunner.run(TestRunner.java:466)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:301)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276)
at org.testng.SuiteRunner.run(SuiteRunner.java:191)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
at org.testng.TestNG.run(TestNG.java:701)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
TEST OFFERS : CATEGORY: PETS & FAMILY
CODE
public static void checkOffers(Vector<String> webIdsToCheck, Vector<Integer> regCompleteCheck, String emailAddress) {
try {
int size = webIdsToCheck.size() - regCompleteCheck.size();
if (size > 0) {
for (int i=0; i<size;i++) {
regCompleteCheck.add(0);
}
System.out.println(size + " REG COMPLETE VALUES ADDED");
}
// Set "en_US" as the safe default
Locale.setDefault( Locale.US );
Connection conn = DBConnection.getConnection();
Statement stmt = conn.createStatement();
ResultSet r;
for (int i=0;i<webIdsToCheck.size();i++) {
r = null;
String webId = webIdsToCheck.elementAt(i);
int regComplete = regCompleteCheck.elementAt(i);
String query = "Select emailaddress, websiteid, regcomplete from " +
"members where emailaddress = '" + emailAddress + "' " +
"AND websiteid='" + webId + "' " + "AND regcomplete =" + regComplete;
System.out.println(query);
// CHANGE SQL QUERY
r = stmt.executeQuery (query);
System.out.println(r.next());
// check if resultset is empty
//assert (r.next());
System.out.println(r.getString(2));
r.close();
Utils.sleep(5000);
}
stmt.close();
//conn.close();
}catch (Exception e) {
e.printStackTrace();
}
}
|
|
|
Re: Java Tester [message #295177 is a reply to message #295173] |
Mon, 21 January 2008 11:00 |
kmmfoo
Messages: 38 Registered: June 2005 Location: massachusetts
|
Member |
|
|
"exhausted resultset" happens when you read past the end of the resultset.
in this case you say
r = stmt.executeQuery (query);
System.out.println(r.next());
System.out.println(r.getString(2));
but what happens if your query returns no records?
instead the r.getString() should always be conditional... like
r = stmt.executeQuery (query);
if (r.next()) {
System.out.println(r.getString(2));
}
HTH...
|
|
|