protected void fillSampleDatabase(Connection conn) throws SQLException {
  info("Start to fill sample database...");
  PreparedStatement orgStmt=conn.prepareStatement("INSERT INTO Organization(id, name, city) VALUES (?, ?, ?)");
  for (int i=0; i < ORGANIZATION_CNT; i++) {
    orgStmt.setInt(1,i);
    orgStmt.setString(2,"name" + i);
    orgStmt.setString(3,"city" + i % 10);
    orgStmt.addBatch();
  }
  orgStmt.executeBatch();
  U.closeQuiet(orgStmt);
  conn.commit();
  PreparedStatement prnStmt=conn.prepareStatement("INSERT INTO Person(id, org_id, birthday, name) VALUES (?, ?, ?, ?)");
  Random rnd=new Random();
  for (int i=0; i < PERSON_CNT; i++) {
    prnStmt.setInt(1,i);
    prnStmt.setInt(2,i % 100);
    prnStmt.setDate(3,Date.valueOf(String.format("%d-%d-%d",1970 + rnd.nextInt(50),1 + rnd.nextInt(11),1 + rnd.nextInt(27))));
    prnStmt.setString(4,"name" + i);
    prnStmt.addBatch();
  }
  prnStmt.executeBatch();
  conn.commit();
  U.closeQuiet(prnStmt);
  info("Sample database prepared.");
}

protected void fillSampleDatabase ( Connection conn ) throws SQLException { info ( "Start to fill sample database..." ) ; PreparedStatement orgStmt = conn . prepareStatement ( "INSERT INTO Organization(id, name, city) VALUES (?, ?, ?)" ) ; for ( int i = 0 ; i < ORGANIZATION_CNT ; i ++ ) { orgStmt . setInt ( 1 , i ) ; orgStmt . setString ( 2 , "name" + i ) ; orgStmt . setString ( 3 , "city" + i % 10 ) ; orgStmt . addBatch ( ) ; } orgStmt . executeBatch ( ) ; U . closeQuiet ( orgStmt ) ; conn . commit ( ) ; PreparedStatement prnStmt = conn . prepareStatement ( "INSERT INTO Person(id, org_id, birthday, name) VALUES (?, ?, ?, ?)" ) ; Random rnd = new Random ( ) ; for ( int i = 0 ; i < PERSON_CNT ; i ++ ) { prnStmt . setInt ( 1 , i ) ; prnStmt . setInt ( 2 , i % 100 ) ; prnStmt . setDate ( 3 , Date . valueOf ( String . format ( "%d-%d-%d" , 1970 + rnd . nextInt ( 50 ) , 1 + rnd . nextInt ( 11 ) , 1 + rnd . nextInt ( 27 ) ) ) ) ; prnStmt . setString ( 4 , "name" + i ) ; prnStmt . addBatch ( ) ; } prnStmt . executeBatch ( ) ; conn . commit ( ) ; U . closeQuiet ( prnStmt ) ; info ( "Sample database prepared." ) ; }
fill in - memory database with sample data .
