lbehnke / h2database

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

Read-Only Access in AUTO_SERVER mode #118

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We would like to use H2 in AUTO_SERVER mode on our development machines so
that we do not have to start the server in code or manually and several
applications are able to access the database at the same time. Some of
these applications should only have read-only access enforced by the DBMS.
When trying a connection string like:
"jdbc:h2:data/database/devdb;AUTO_SERVER=TRUE;ACCESS_MODE_DATA=r"

the following exception is thrown:
Feature not supported: autoServerMode && (readOnly || fileLockMethod == NO)
[50100-116]
    at org.h2.message.Message.getSQLException(Message.java:105)
    at org.h2.message.Message.getSQLException(Message.java:116)
    at org.h2.message.Message.getSQLException(Message.java:75)
    at org.h2.message.Message.getUnsupportedException(Message.java:161)
    at org.h2.engine.Database.open(Database.java:565)
    at org.h2.engine.Database.openDatabase(Database.java:220)
    at org.h2.engine.Database.<init>(Database.java:215)
    at org.h2.engine.Engine.openSession(Engine.java:58)
    at org.h2.engine.Engine.openSession(Engine.java:140)
    at org.h2.engine.Engine.getSession(Engine.java:120)
    at
org.h2.engine.SessionFactoryEmbedded.createSession(SessionFactoryEmbedded.java:1
7)
    at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:245)
    at org.h2.engine.SessionRemote.createSession(SessionRemote.java:223)
    at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
    at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
    at org.h2.Driver.connect(Driver.java:58)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)

How important/urgent is the problem for you?
It would be really cool and helpful for our develpment environment
requiring minimal changes in configuration and no changes in code.

In your view, is this a defect or a feature request?
Feature request

Original issue reported on code.google.com by k...@schneide.com on 15 Sep 2009 at 1:37

GoogleCodeExporter commented 9 years ago
Hi,

H2 only supports read-only database, it doesn't support read-only sessions yet. 
This
feature is on the roadmap under "Set a connection read only
(Connection.setReadOnly)", I will extend it to: "Set a connection read only
(Connection.setReadOnly) or using a connection parameter" because you probably 
don't
want to change the code to use this feature, only the URL. I will also increase 
the
priority of this feature.

There is a workaround: you could create a second user that only has read-only 
access
to the data. Would that solve your problem?

Original comment by thomas.t...@gmail.com on 19 Sep 2009 at 9:13

GoogleCodeExporter commented 9 years ago
This feature is on the roadmap, and priority will be tracked there.

Original comment by thomas.t...@gmail.com on 22 Sep 2009 at 4:27