org.h2.Driver.load();
deleteDb("openClose");
final String url = getURL("openClose;FILE_LOCK=NO", true);
final String user = getUser(), password = getPassword();
Connection conn = DriverManager.getConnection(url, user, password);
conn.createStatement().execute("drop table employee if exists");
conn.createStatement().execute("create table employee(id int primary key, name varchar, salary int)");
conn.close();
// previously using getSize(200, 1000);
// but for Ubuntu, the default ulimit is 1024,
// which breaks the test
int len = getSize(10, 50);
Task[] tasks = new Task[len];
for (int i = 0; i < len; i++) {
tasks[i] = new Task() {
public void call() throws SQLException {
Connection c = DriverManager.getConnection(url, user, password);
PreparedStatement prep = c.prepareStatement("insert into employee values(?, ?, 0)");
int id = getNextId();
prep.setInt(1, id);
prep.setString(2, "employee " + id);
prep.execute();
c.close();
}
};
tasks[i].execute();
}
// for(int i=0; i<len; i++) {