void run(String driver,String url,String user,String password) throws Exception {
  Class.forName(driver);
  conn=DriverManager.getConnection(url,user,password);
  stat=conn.createStatement();
  try {
    stat.execute("DROP TABLE USERS");
  }
 catch (  SQLException e) {
  }
  stat.execute("CREATE TABLE USERS(ID INT PRIMARY KEY, " + "NAME VARCHAR(255), PASSWORD VARCHAR(255))");
  stat.execute("INSERT INTO USERS VALUES(1, 'admin', 'super')");
  stat.execute("INSERT INTO USERS VALUES(2, 'guest', '123456')");
  stat.execute("INSERT INTO USERS VALUES(3, 'test', 'abc')");
  loginByNameInsecure();
  if (url.startsWith("jdbc:h2:")) {
    loginStoredProcedureInsecure();
    limitRowAccess();
  }
  loginByNameSecure();
  if (url.startsWith("jdbc:h2:")) {
    stat.execute("SET ALLOW_LITERALS NONE");
    stat.execute("SET ALLOW_LITERALS NUMBERS");
    stat.execute("SET ALLOW_LITERALS ALL");
  }
  loginByIdInsecure();
  loginByIdSecure();
  try {
    stat.execute("DROP TABLE ITEMS");
  }
 catch (  SQLException e) {
  }
  stat.execute("CREATE TABLE ITEMS(ID INT PRIMARY KEY, " + "NAME VARCHAR(255), ACTIVE INT)");
  stat.execute("INSERT INTO ITEMS VALUES(0, 'XBox', 0)");
  stat.execute("INSERT INTO ITEMS VALUES(1, 'XBox 360', 1)");
  stat.execute("INSERT INTO ITEMS VALUES(2, 'PlayStation 1', 0)");
  stat.execute("INSERT INTO ITEMS VALUES(3, 'PlayStation 2', 1)");
  stat.execute("INSERT INTO ITEMS VALUES(4, 'PlayStation 3', 1)");
  listActiveItems();
  if (url.startsWith("jdbc:h2:")) {
    stat.execute("DROP CONSTANT IF EXISTS TYPE_INACTIVE");
    stat.execute("DROP CONSTANT IF EXISTS TYPE_ACTIVE");
    stat.execute("CREATE CONSTANT TYPE_INACTIVE VALUE 0");
    stat.execute("CREATE CONSTANT TYPE_ACTIVE VALUE 1");
    listActiveItemsUsingConstants();
  }
  listItemsSortedInsecure();
  listItemsSortedSecure();
  if (url.startsWith("jdbc:h2:")) {
    listItemsSortedSecureParam();
    storePasswordHashWithSalt();
  }
  conn.close();
}

void run ( String driver , String url , String user , String password ) throws Exception { Class . forName ( driver ) ; conn = DriverManager . getConnection ( url , user , password ) ; stat = conn . createStatement ( ) ; try { stat . execute ( "DROP TABLE USERS" ) ; } catch ( SQLException e ) { } stat . execute ( "CREATE TABLE USERS(ID INT PRIMARY KEY, " + "NAME VARCHAR(255), PASSWORD VARCHAR(255))" ) ; stat . execute ( "INSERT INTO USERS VALUES(1, 'admin', 'super')" ) ; stat . execute ( "INSERT INTO USERS VALUES(2, 'guest', '123456')" ) ; stat . execute ( "INSERT INTO USERS VALUES(3, 'test', 'abc')" ) ; loginByNameInsecure ( ) ; if ( url . startsWith ( "jdbc:h2:" ) ) { loginStoredProcedureInsecure ( ) ; limitRowAccess ( ) ; } loginByNameSecure ( ) ; if ( url . startsWith ( "jdbc:h2:" ) ) { stat . execute ( "SET ALLOW_LITERALS NONE" ) ; stat . execute ( "SET ALLOW_LITERALS NUMBERS" ) ; stat . execute ( "SET ALLOW_LITERALS ALL" ) ; } loginByIdInsecure ( ) ; loginByIdSecure ( ) ; try { stat . execute ( "DROP TABLE ITEMS" ) ; } catch ( SQLException e ) { } stat . execute ( "CREATE TABLE ITEMS(ID INT PRIMARY KEY, " + "NAME VARCHAR(255), ACTIVE INT)" ) ; stat . execute ( "INSERT INTO ITEMS VALUES(0, 'XBox', 0)" ) ; stat . execute ( "INSERT INTO ITEMS VALUES(1, 'XBox 360', 1)" ) ; stat . execute ( "INSERT INTO ITEMS VALUES(2, 'PlayStation 1', 0)" ) ; stat . execute ( "INSERT INTO ITEMS VALUES(3, 'PlayStation 2', 1)" ) ; stat . execute ( "INSERT INTO ITEMS VALUES(4, 'PlayStation 3', 1)" ) ; listActiveItems ( ) ; if ( url . startsWith ( "jdbc:h2:" ) ) { stat . execute ( "DROP CONSTANT IF EXISTS TYPE_INACTIVE" ) ; stat . execute ( "DROP CONSTANT IF EXISTS TYPE_ACTIVE" ) ; stat . execute ( "CREATE CONSTANT TYPE_INACTIVE VALUE 0" ) ; stat . execute ( "CREATE CONSTANT TYPE_ACTIVE VALUE 1" ) ; listActiveItemsUsingConstants ( ) ; } listItemsSortedInsecure ( ) ; listItemsSortedSecure ( ) ; if ( url . startsWith ( "jdbc:h2:" ) ) { listItemsSortedSecureParam ( ) ; storePasswordHashWithSalt ( ) ; } conn . close ( ) ; }
run the test against the specified database .
