Cannot turn off auto commit?
[email protected] Wed, 7 Sep 2016 20:18:49 +0000
| Newsgroups | gmane.comp.java.hsqldb.user |
|---|---|
| Organization | io7m.com |
| Message-ID | <[email protected]> |
Hello.
The following trivial example seems like it should not commit anything
to the database, but it does.
public static void main(
final String[] args)
throws Exception
{
final Properties props = new Properties();
props.setProperty("user", "SA");
props.setProperty("password", "");
props.setProperty("create", "true");
props.setProperty("shutdown", "false");
props.setProperty("sql.enforce_types", "true");
props.setProperty("sql.enforce_names", "true");
props.setProperty("sql.regular_names", "true");
props.setProperty("sql.enforce_refs", "true");
props.setProperty("sql.enforce_size", "true");
props.setProperty("sql.enforce_types", "true");
props.setProperty("sql.enforce_types", "true");
props.setProperty("hsqldb.applog", "3");
props.setProperty("hsqldb.sqllog", "3");
final JDBCDataSource ds = new JDBCDataSource();
ds.setUrl("jdbc:hsqldb:file:/tmp/example");
ds.setProperties(props);
try (final Connection conn = ds.getConnection()) {
conn.setAutoCommit(false);
try (final PreparedStatement st =
conn.prepareStatement("CREATE CACHED TABLE broken (x INTEGER)")) {
st.execute();
}
}
}
I can add explicit calls to conn.rollback(), but the commit still
occurs. If I run the program twice, the second execution throws
an exception because the "broken" table exists. It should not!
What am I doing wrong?
M
------------------------------------------------------------------------------
_______________________________________________
Hsqldb-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hsqldb-user
signature.asc
(application/pgp-signature, 821 B)
-----BEGIN PGP SIGNATURE----- iQIrBAEBCgAVBQJX0HYpDhxtYXJrQGlvN20uY29tAAoJEAKt2nV+RgR4l2wP/Awx UZByhy/uXzPLQuyZr5k+Q61T3ZhU9wE7tQKuCaHlkRae24c0zMMnQq+FM2SeF67i v998X/MdrEiOfFCslH4aqTVNUoLPzYsbdBx1JpXyXFbqdENnCW0r5Z8UowsYZl/0 oJmuaFbU7IM9FCAlo6ScLDNih5145IyTeMZWDe5eF23BmsKUpJ+dHV7mtJvQDSoX m64Nh5aLqmvyUH03+wQBzrIDcqbqFFusig55R5c/o4TWkXI8WSPn1BtZT7IS8VMM dYCcMMG5QhS64Bh3+x59JaFZC+XInPN0IWoui/4HBnGcphN+Fpjg/gBg63AybeBq JGnbrg6kCRmbx+FOBgxXMlkOOTutkcxB3BTrfoQeuBTbfCP5Me4mP7M+Cn8yOF/h qWTEOoyB5z3zrqRExGemmXk7o4ZIwvZca2W0Ppb7Z8k1LgL9ZVdumOOCDVAoWCBs /PR/9p+YQKn4xAiQWxF5jx9VTRok/e0mMSqphyCn5RCMnF6ttapZt39cm2rCnrPw tJ+a4GmA56tH+6jAX9JarpaK3PdpInsT60+4ZIW2ANONgILFSpJa19dNSO70R4ht j+54iyARcvRJD6qd+PJ7lgVORIhoLdw9rjmcuHs5rkdNQMYKdWLXPAu2NIkQdFUN ehxZw4vko/Yg6zdLYvCi1dwPCbE4Pjof/5XcYj/M =CatI -----END PGP SIGNATURE-----