public void testBug71672Statement(int testStep,Connection testConn,String query,int expectedUpdateCount,int[] expectedKeys) throws SQLException {
  Statement testStmt=testConn.createStatement();
  if (expectedUpdateCount < 0) {
    assertFalse(testStep + ". Stmt.execute() result",testStmt.execute(query,Statement.RETURN_GENERATED_KEYS));
  }
 else {
    assertEquals(testStep + ". Stmt.executeUpdate() result",expectedUpdateCount,testStmt.executeUpdate(query,Statement.RETURN_GENERATED_KEYS));
  }
  ResultSet testRS=testStmt.getGeneratedKeys();
  for (  int k : expectedKeys) {
    assertTrue(testStep + ". Row expected in generated keys ResultSet",testRS.next());
    assertEquals(testStep + ". Wrong generated key",k,testRS.getInt(1));
  }
  assertFalse(testStep + ". No more rows expected in generated keys ResultSet",testRS.next());
  testRS.close();
  testStmt.close();
}

public void testBug71672Statement ( int testStep , Connection testConn , String query , int expectedUpdateCount , int [ ] expectedKeys ) throws SQLException { Statement testStmt = testConn . createStatement ( ) ; if ( expectedUpdateCount < 0 ) { assertFalse ( testStep + ". Stmt.execute() result" , testStmt . execute ( query , Statement . RETURN_GENERATED_KEYS ) ) ; } else { assertEquals ( testStep + ". Stmt.executeUpdate() result" , expectedUpdateCount , testStmt . executeUpdate ( query , Statement . RETURN_GENERATED_KEYS ) ) ; } ResultSet testRS = testStmt . getGeneratedKeys ( ) ; for ( int k : expectedKeys ) { assertTrue ( testStep + ". Row expected in generated keys ResultSet" , testRS . next ( ) ) ; assertEquals ( testStep + ". Wrong generated key" , k , testRS . getInt ( 1 ) ) ; } assertFalse ( testStep + ". No more rows expected in generated keys ResultSet" , testRS . next ( ) ) ; testRS . close ( ) ; testStmt . close ( ) ; }
check the update count and returned keys for an insert query using a statement object . if expectedupdatecount < 0 then runs statement . execute ( ) otherwise statement . executeupdate ( ) .
