java + sqlite: how to open database as read-only? java + sqlite: how to open database as read-only? sqlite sqlite

java + sqlite: how to open database as read-only?


Test demonstrate how to set connection to be read-only:

SQLiteConfig config = new SQLiteConfig();config.setReadOnly(true); Connection conn = DriverManager.getConnection("jdbc:sqlite:sample.db",config.toProperties());


Try this.

Properties config = new Properties();config.setProperty("open_mode", "1");  //1 == readonlyConnection conn = DriverManager.getConnection("jdbc:sqlite:sample.db", config);


Just want to add that when using HikariCP, you need two datasource properties:

readOnly=truedataSource.open_mode=1