小编Ral*_*phP的帖子

使用Java从磁盘备份和恢复sqlite到内存

我正在尝试将sqlite-File读入内存以获得更好的性能,在关闭我的应用程序时我想将其写回到hdd.

我在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());
}
Run Code Online (Sandbox Code Playgroud)

文件存在(及其有效的sqlite数据库)this._conn是打开的,但如果我想在其上执行语句,则看起来里面没有表或数据.它似乎无法恢复任何东西.

有关如何进一步解决/调试的任何建议?

(顺便说一句 - 如果我stat.executeUpdate("backup to test.db")在我的连接上使用它,它会备份我的空:memory:db ......)

java sqlite jdbc

7
推荐指数
1
解决办法
4222
查看次数

标签 统计

java ×1

jdbc ×1

sqlite ×1