I am trying to use different isolation levels for my application due to a problem with concurrent updates. I set the isolation level through the DataSource from which I get the database connection
BasicDataSource ds = new BasicDataSource(); ds.setDefaultTransactionIsolation( Connection.TRANSACTION_REPEATABLE_READ) ds.getConnection()
When using postgres 9.3 database, simultaneous updates in rows trigger an error, which is expected according to the postgres documentation on Standard SQL Transaction Isolation Levels
ERROR: could not serialize access due to read/write dependencies among transactions This error disappears as expected when setting the isolation level to Connection.TRANSACTION_READ_COMMITTED
Trying to reproduce this behavior with an H2 database in memory, isolation levels do not seem to change the result of my unittest. Even when deactivating isolation in general with setting the database URL with LOCK_MODE = 0 and / or Connection.TRANSACTION_READ_UNCOMMITTED I get errors while updating org.h2.jdbc.JdbcSQLException: Concurrent update in table "MyTable": another transaction has updated or deleted the same row
My question is: How do I configure an H2 connection to use a certain isolation level, none of my changes in lock mode or connection help me get rid of JdbcSQLException.
source share