Created
February 10, 2009 15:24
-
-
Save lebesnec/61424 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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