Skip to content

Instantly share code, notes, and snippets.

@lebesnec
Created February 10, 2009 15:24
Show Gist options
  • Save lebesnec/61424 to your computer and use it in GitHub Desktop.
Save lebesnec/61424 to your computer and use it in GitHub Desktop.
public void initTables() {
Statement statement1 = null;
PreparedStatement statement2 = null;
try {
statement1 = connection.createStatement();
statement1.execute("create table people(name varchar(40) not null, age int)");
connection.commit();
statement2 = connection.prepareStatement("insert into people values (?, ?)");
statement2.setString(1, "foo");
statement2.setInt(2, 20);
statement2.executeUpdate();
connection.commit();
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
try {
statement1.close();
statement2.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment