I don't know if this is in the right forum (move it if not please).
I'm writing a unit test with Junit and DBUnit.
The error i've got is
SQLException: No data is available
Pieces of code:
setUp method
super.setUp();
ds = new BasicDataSource();
((BasicDataSource) ds).setDriverClassName("org.hsqldb.jdbcDriver");
((BasicDataSource) ds).setUrl("jdbc:hsqldb:mem:baseball");
((BasicDataSource) ds).setUsername("sa");
((BasicDataSource) ds).setPassword("");
conn = ds.getConnection();
Statement stm = conn.createStatement();
stm.execute(SQL_CREATE_TABLE);
stm.close();
ObjToTest obj = new ObjToTest();
ObjToTest.setDataSource(ds);
testCommit method
public void testCommit(){
try {
obj.commit(1L, 1L, null, "", "", true, null);
} catch (Exception e) {
getLogger().debug("Exception caught", e);
fail("Exception caught");
}
try {
conn = ds.getConnection();
} catch (SQLException e1) {
getLogger().debug("SQLException caught", e1);
}
Statement stm = null;
ResultSet rs = null;
int response = 0;
try {
stm = conn.createStatement();
rs = stm.executeQuery(SQL_SELECT_VALUE);
response = rs.getInt(1);
} catch (SQLException e) {
getLogger().debug("SQLException caught", e);
fail(e.toString());
}
assertEquals(response, EXPECTED_RESPONSE);
}
Everything seems to work fine until this line:
response = rs.getInt(1);
Any ideas?
Thanks.