3

I want to use the Write-Ahead Logging feature of SQLite in a j2se program. Please help me with a java implemention example.

1 Answer 1

4

You need to execute a Sqlite specific command (just like you'd execute other SQL queries):

pragma journal_mode=wal

For the specifics of using this pragma, please read http://www.sqlite.org/pragma.html#pragma_journal_mode

Here are some highlights:

  • Your Sqlite library must be >= 3.7.0.
  • This journal_mode is persistent (or sticky), ie you'll need to disable it explicitly if you want to access your database with a < 3.7.0 Sqlite.
Sign up to request clarification or add additional context in comments.

5 Comments

Note that this command will return a result set -- a detail missed in the Xerial SQLite JDBC wrapper, as reported here: code.google.com/p/sqlite-jdbc/issues/detail?id=7
@sixfeetsix: Does this means that i have to write a statement like stmt.execute("pragma journal_mode=WAL"); in my java program ? But i don't see any increase in performance with this statement.
@sam: yes, execute the statement as any other sql; as seh mentions, this pragma is particular as it returns a result set with the resulting journal_mode, so please make sure you get "wal". If you do get "wal", then I guess using WAL wasn't what ou needed to do to increase performance. If you want help with that, I suggest you create a new question where you'll describe what it is that is slow by providing the enough context to allow the community to help you (eg how much time a query takes, what is the query, what is/are the table structure(s), a sample of the typical records, etc.)
@sixfeetsix: The problem is "pragma journal_mode=WAL" is supported by SQLite 3.7 but there are no compatible jdbc drivers for this new version and the default mode does not changing through older drivers.
@sam: doesn't the workaround in code.google.com/p/sqlite-jdbc/issues/detail?id=7 work for you?

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.