Hi,
How do a execute multiple statements using JDBC as one atomic transaction?
I'm using 1.1.116.
I have tried the code below, but table xyz is always created. The second
executeUpdate() always throws an SQLException, and the rollback is
performed, but the table still exists?
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:/tmp/x", "sa", "");
try {
conn.setAutoCommit(false);
Statement sth = conn.createStatement();
try {
try {
sth.executeUpdate("create table xyz(id int)");
sth.executeUpdate("some invalid sql");
conn.commit();
}catch (SQLException exception){
conn.rollback();
}
}finally{
sth.close();
}
}finally{
conn.close();
}
Thanks,
Jesse
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---