testing for insertRow
This commit is contained in:
parent
164e1bc913
commit
422c2e38a1
@ -28,24 +28,26 @@ public class UpdateableResultTest extends TestCase
|
|||||||
Connection con = TestUtil.openDB();
|
Connection con = TestUtil.openDB();
|
||||||
TestUtil.createTable(con, "updateable","id int primary key, name text, notselected text");
|
TestUtil.createTable(con, "updateable","id int primary key, name text, notselected text");
|
||||||
TestUtil.createTable(con, "second","id1 int primary key, name1 text");
|
TestUtil.createTable(con, "second","id1 int primary key, name1 text");
|
||||||
Statement st1 = con.createStatement();
|
|
||||||
boolean retVal = st1.execute( "insert into updateable ( id, name, notselected ) values (1, 'jake', 'avalue')" );
|
|
||||||
assertTrue(!retVal);
|
|
||||||
|
|
||||||
retVal = st1.execute( "insert into second (id1, name1) values (1, 'jake')" );
|
// put some dummy data into second
|
||||||
assertTrue( !retVal );
|
Statement st2 = con.createStatement();
|
||||||
st1.close();
|
st2.execute( "insert into second values (1,'anyvalue' )");
|
||||||
|
st2.close();
|
||||||
|
|
||||||
Statement st = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );
|
Statement st = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );
|
||||||
ResultSet rs = st.executeQuery( "select id, name, notselected from updateable" );
|
ResultSet rs = st.executeQuery( "select * from updateable");
|
||||||
|
assertNotNull( rs );
|
||||||
|
rs.moveToInsertRow();
|
||||||
|
rs.updateInt( 1, 1 );
|
||||||
|
rs.updateString( 2, "jake" );
|
||||||
|
rs.updateString( 3, "avalue" );
|
||||||
|
rs.insertRow();
|
||||||
|
rs.first();
|
||||||
|
|
||||||
assertNotNull(rs);
|
|
||||||
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
rs.updateInt( "id",2 );
|
rs.updateInt( "id",2 );
|
||||||
rs.updateString( "name","dave" );
|
rs.updateString( "name","dave" );
|
||||||
rs.updateRow();
|
rs.updateRow();
|
||||||
|
|
||||||
assertTrue( rs.getInt("id") == 2 );
|
assertTrue( rs.getInt("id") == 2 );
|
||||||
assertTrue( rs.getString("name").equals("dave"));
|
assertTrue( rs.getString("name").equals("dave"));
|
||||||
assertTrue( rs.getString("notselected").equals("avalue") );
|
assertTrue( rs.getString("notselected").equals("avalue") );
|
||||||
@ -61,7 +63,6 @@ public class UpdateableResultTest extends TestCase
|
|||||||
assertTrue( rs.getString("name").equals("paul"));
|
assertTrue( rs.getString("name").equals("paul"));
|
||||||
assertTrue( rs.getString("notselected") == null );
|
assertTrue( rs.getString("notselected") == null );
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user