Backup and restore sqlite from disk to memory in Java Backup and restore sqlite from disk to memory in Java sqlite sqlite

Backup and restore sqlite from disk to memory in Java


It looks like you are missing two things: 1) The quotes around the file name, and 2) stat.close. Try the following:

this._conn = DriverManager.getConnection("jdbc:sqlite:");Statement stat  = this._conn.createStatement();File dbFile = new File(this._config.GetDataBaseFile());if (dbFile.exists()) {    this._logger.AddInfo("File exists.");    stat.executeUpdate("restore from '" + dbFile.getAbsolutePath() + "'");    stat.close();}

That was the only way I could get it to work with Xerial SQLite JDBC version 3.7.15-M1. I do not think that the version matters much in this case.


The quotes and stat.close() don't matter, according to the link: `https://bitbucket.org/xerial/sqlite-jdbc/wiki/Usage', which I have tested. Quotes help when file path contains spaces, though.

I think it maybe due to the jdbc driver. Try Xerial's JDBC driver for SQLite, which works fine for me.