2

After reading the Sqlite documentation I wanted to make sure that by run-time the connection to the database is in the correct mode.

Class.forName("org.sqlite.JDBC");
Connection connection = DriverManager.getConnection("jdbc:sqlite::memory:");

I'm using the Sqlite JDBC driver. How can I add the SQLITE_OPEN_NOMUTEX flag?

2
  • Please check this link it asked before at C# stackoverflow.com/questions/7801361/multithreading-in-sqlite Commented Jul 1, 2014 at 15:08
  • The conclusion is that the Sqlite database runs in serialized mode by default and I can't change it. :-( Commented Jul 1, 2014 at 16:30

1 Answer 1

4

After I had some doubts why in C it looks so easy and in Java it should not possible, here probably the solution:

Class.forName("org.sqlite.JDBC");

SQLiteConfig config = new SQLiteConfig();
config.setOpenMode(SQLiteOpenMode.READWRITE);
config.setOpenMode(SQLiteOpenMode.CREATE);
config.setOpenMode(SQLiteOpenMode.NOMUTEX);

Connection connection = DriverManager.getConnection( //
              "jdbc:sqlite::memory:", //
              config.toProperties() //
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.