Server Mode and Autocommit=OFF

1,327 views
Skip to first unread message

Akshay Mehta

unread,
Mar 6, 2014, 9:31:54 AM3/6/14
to h2-da...@googlegroups.com
Hi,

I have an application which starts a TCP Server using the Server class. Once the server is started the application then tries to establish the connection (the database might not exists) using 

Server h2server = Server.createTcpServer(new String[]{"-tcpAllowOthers", "-tcpPort", "9090", "-baseDir", "somepath"});
h2server = h2server.start();

Connection con = DriverManager.getConnection("jdbc:h2:tcp://localhost:9090/test;mvcc=true;autocommit=off");

immediately after this when I issue the command "con.getAutoCommit()" always returns a true.

This also happens when using the connection string as follows and not starting the server before hand:

DriverManager.getConnection("jdbc:h2:tcp://localhost/~/test;mvcc=true;autocommit=off");

While "con.getAutoCommit()" returns a false when using the connection string with "jdbc:h2:file:".

Am I doing something wrong or is the AutoCommit=off not supported in Server Mode?

regards
Akshay Mehta

Noel Grandin

unread,
Mar 9, 2014, 3:24:57 PM3/9/14
to h2-da...@googlegroups.com
It's not supported in server mode. 
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.

Thomas Mueller

unread,
Apr 16, 2014, 1:08:21 AM4/16/14
to h2-da...@googlegroups.com
Hi,

I found it a bit weird and investigated. In server mode, appending ";autocommit=false" to the database URL is actually working, but the return value of Connection.getAutoCommit() is wrong (until you execute the first statement I believe). So, is a bug, and it will be fixed in the next version.

But, I don't recommend using this setting. Why don't you use Connection.setAutoCommit(false) instead? All databases support that.

Regards,
Thomas
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages