Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DBUnit problem

843859Apr 9 2007 — edited Apr 9 2007
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 7 2007
Added on Apr 9 2007
1 comment
219 views