0

I use ORMLite and SQLite in memory database for speed. After operation, I need to backup the in memory database to a file, but could's find a method to do that.

In another thread (Backup and restore sqlite from disk to memory in Java) shown a method with JDBC Connection, therefor my question can be narrowed down to: If I have had a ORMLite ConnectionSource object, how can I get a JDBC Connection object from it?

Thanks

4
  • I found a useful thread: stackoverflow.com/questions/12374848/…; simple as : JdbcDatabaseConnection.getInternalConnection(); Commented Mar 10, 2015 at 6:20
  • backup works fine: (JdbcDatabaseConnection) getSharedConnectionSource().getReadWriteConnection().getInternalConnection().createStatement().executeUpdate("backup to data.db");; <p>however, restore doesn't work: jdbcDatabaseConnection = (JdbcDatabaseConnection) getSharedConnectionSource().getReadWriteConnection().getInternalConnection().createStatement().executeUpdate("restore from data.db"); Commented Mar 10, 2015 at 16:40
  • "Restore" doesn't work because SQLite doesn't support connection pool (JdbcPooledConnectionSource) for in-memory mode...I think. Using JdbcConnectionSource does then restoring job. Commented Mar 11, 2015 at 0:33
  • Problem solved!. Connecting string "jdbc:sqlite:file::memory:?cache=shared" solved it. Commented Mar 12, 2015 at 9:04

0

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.