I have a problem. After adding some data to database, I need to set read-only mode for whole DB. What is the easiest way to do that using h2 embedded DB with driver manager (jdbc)?
Class.forName("org.h2.Driver").newInstance(); con = DriverManager.getConnection("jdbc:h2:" + "./"+dbName, "hereIsUser", "hereIsPassword");
You can open the whole database in read-only mode by appending
;ACCESS_MODE_DATA=rto the JDBC URL (
"jdbc:h2:" + "./" + dbName + ";ACCESS_MODE_DATA=r"in your case.
You can create a separate user (
CREATE USER userName PASSWORD 'some_password') and give it only the
GRANT SELECT ON SCHEMA nameOfYourSchema TO userName) and use that user.