Thanks Bob, That explains it.
+1 vote for feature +1 vote for for this to be documented Cheers, Jesse bob mcgee wrote: > Hello Jesse, > Most data definition language statements are not currently > transactional. It's on the Roadmap for future development, but a lot > of the major databases don't include this feature, so it isn't on the > priority-1 list. > > Cheers, > Bob McGee > > On Jul 21, 9:45 am, Jesse Long <[email protected]> wrote: > >> 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 -~----------~----~----~----~------~----~------~--~---
