jimcoly / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

This combination of database settings is not supported: "LOCK_MODE=0 & MULTI_THREADED" #581

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently using 1.4.181. I'm testing the multithreaded feature but H2 is 
throwing this error when I connect. I have loaded the database in the H2 
console with this url:

jdbc:h2:tcp://localhost//home/.../database;MAX_QUERY_TIMEOUT=1300000;DB_CLOSE_DE
LAY=-1;LOCK_MODE=3;MULTI_THREADED=TRUE

This allows me to connect via the H2 console. However when I try to connect in 
my jdbc application using the same URL, I get the error mentioned: combination 
of settings not supported.

I don't think H2 is using the LCOK_MODE setting as configured in the URL? Is 
there anything I can do in my code to get around this? 

When I use H2 console and execute: SELECT * FROM INFORMATION_SCHEMA.SETTINGS; I 
get a table which shows LOCK_MODE is equal to 3, so for the H2 console at 
least, the URL does work. It's just in my java application, connecting with the 
same URL, that the jdbc java app throws this error.

Original issue reported on code.google.com by localde...@gmail.com on 3 Sep 2014 at 3:52

GoogleCodeExporter commented 9 years ago
Ok; found the code that it's throwing the error on. The code executes this 
block:

Connection connection = DriverManager.getConnection(p.getUrl(), 
p.getUsername(), p.getPassword());
DatabaseMetaData dmd = connection.getMetaData();
if 
(dmd.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED))
    connection.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);

The error is thrown on the last line while setting the isolation. So it looks 
like H2 is saying UNCOMMITTED is supported; but maybe it shouldn't return true 
here if it is running in MULTI_THREADED mode?

Any thoughts?

Original comment by localde...@gmail.com on 3 Sep 2014 at 3:59

GoogleCodeExporter commented 9 years ago
what does the exception trace look like?

Original comment by noelgrandin on 4 Sep 2014 at 12:19

GoogleCodeExporter commented 9 years ago
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;

public class tester {
    public static void main(String... args) throws Exception {
        Class.forName("org.h2.Driver");
        Connection connection = DriverManager.getConnection("jdbc:h2:tcp://pathToDatabase;MULTI_THREADED=TRUE;LOCK_MODE=3;", "sa", "sa");
        DatabaseMetaData dmd = connection.getMetaData();
        if (dmd.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED))
            connection.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
        System.out.println("done");
    }//main
}//tester

############################################

Stacktrace:

Exception in thread "main" org.h2.jdbc.JdbcSQLException: This combination of 
database settings is not supported: "LOCK_MODE=0 & MULTI_THREADED"; SQL 
statement:
SET LOCK_MODE ? [90021-181]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.message.DbException.get(DbException.java:155)
    at org.h2.engine.Database.setLockMode(Database.java:2092)
    at org.h2.command.dml.Set.update(Set.java:262)
    at org.h2.command.CommandContainer.update(CommandContainer.java:78)
    at org.h2.command.Command.executeUpdate(Command.java:254)
    at org.h2.server.TcpServerThread.process(TcpServerThread.java:345)
    at org.h2.server.TcpServerThread.run(TcpServerThread.java:159)
    at java.lang.Thread.run(Thread.java:724)

    at org.h2.engine.SessionRemote.done(SessionRemote.java:622)
    at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:191)
    at org.h2.jdbc.JdbcConnection.setTransactionIsolation(JdbcConnection.java:720)
    at tester.main(tester.java:13)
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)

Original comment by localde...@gmail.com on 4 Sep 2014 at 1:49

GoogleCodeExporter commented 9 years ago
Thanks for the test case, this is fixed and will be released in 1.4.183

Original comment by noelgrandin on 20 Oct 2014 at 7:07