我想读取一个sqlite文件到内存中以获得更好的性能,当关闭我的应用程序时我想把它写回硬盘。备份和恢复SQLite从磁盘到Java中的内存
我在Java中使用了jdbc(3.7.2)驱动程序。
根据该文档,我的代码看起来像
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());
}
文件存在(及其有效的sqlite的分贝),this._conn
是开放的,但如果我想执行它的语句,似乎有里面没有表格和数据。它似乎并没有恢复任何东西。
关于如何解决/进一步调试的任何建议?
(顺便说一句 - 如果我我的连接上使用stat.executeUpdate("backup to test.db")
,它备份我的空:内存:DB ...)
该文件存在,它是一个有效的SQLite数据库 - 但它包含任何表? – mthmulders
是的,它的确如此。还有数据。 – RalphP
@ mjreaper..did你找到这个代码的解决方案?你能帮助我如何恢复? –