2

I am using SQLite DB and I have multiple threads using a single connection. As per https://www.sqlite.org/threadsafe.html I think I need to use serialized mode.

How can I set threading mode in Java? I mean method?

SQLiteConfig config = new SQLiteConfig();
config.setOpenMode(SQLiteOpenMode.FULLMUTEX);
dbc = DriverManager.getConnection(jdbcPath,config.toProperties());

Is there any relation between SQLiteOpen mode and Threading Mode ?

SQLite supports three different threading modes:

Single-thread. In this mode, all mutexes are disabled and SQLite is unsafe to use in more than a single thread at once.

Multi-thread. In this mode, SQLite can be safely used by multiple threads provided that no single database connection is used simultaneously in two or more threads.

Serialized. In serialized mode, SQLite can be safely used by multiple threads with no restriction.

2
  • stackoverflow.com/questions/10707434/… Commented Jan 31, 2017 at 7:16
  • @tuxdna that link suggesting me to have Share the same JDBC connection among all threads, thats what I am doing it now, But I want to make sure "Threading Mode is Set to Serialized", how can I do that? Sorry If I misinterpret the answer link, but I am not sure how to set threading mode? in Java Commented Jan 31, 2017 at 7:24

1 Answer 1

2

From the link you posted:

The default mode is serialized.

If you want to explicitly select the serialized mode (or switch back to it), then use SQLiteOpenMode.FULLMUTEX as is also described in the docs.

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.