- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
从 JDBC 读取 SQLite 数据库时出现以下错误:[SQLITE_NOTADB] 打开的文件不是数据库文件(文件已加密或不是数据库)
。据我所知,这个数据库没有加密(见下面的标题)并且 sqlite3 能够执行相同的命令而没有任何错误或警告。
有什么解决这个问题的建议/想法吗?
源代码
package foo;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Test {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Connection connection = null;
Statement statement = null;
String fn = "/Users/jerome/db.sql";
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection("jdbc:sqlite:" + fn);
statement = connection.createStatement();
statement.executeQuery("SELECT 1 FROM sqlite_master");
}
}
如何运行
java -cp /Users/jerome/.m2/repository/org/xerial/sqlite-jdbc/3.7.2/sqlite-jdbc-3.7.2.jar:foo.jar foo.Test
堆栈跟踪
Exception in thread "main" java.sql.SQLException: [SQLITE_NOTADB] File opened that is not a database file (file is encrypted or is not a database)
at org.sqlite.DB.newSQLException(DB.java:383)
at org.sqlite.DB.newSQLException(DB.java:387)
at org.sqlite.DB.throwex(DB.java:374)
at org.sqlite.NestedDB.prepare(NestedDB.java:134)
at org.sqlite.DB.prepare(DB.java:123)
at org.sqlite.Stmt.executeQuery(Stmt.java:121)
at foo.Test.main(Test.java:16)
使用 sqlite3
sqlite3 ~/Desktop/db.sql "SELECT 1 FROM sqlite_master"
1
1
[...]
1
数据库 header
hexdump -C ~/Desktop/db.sql | head
00000000 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 |SQLite format 3.|
00000010 10 00 02 02 00 40 20 20 00 00 2e 0b 00 00 01 7c |.....@ .......||
00000020 00 00 00 00 00 00 00 00 00 00 00 21 00 00 00 04 |...........!....|
00000030 00 00 00 00 00 00 00 24 00 00 00 01 00 00 00 00 |.......$........|
00000040 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2e 0b |................|
00000060 00 2d e2 25 05 00 00 00 01 0f fb 00 00 00 00 25 |.-.%...........%|
00000070 0f fb 04 bf 04 20 03 78 02 cd 02 22 01 92 00 f9 |..... .x..."....|
00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
最佳答案
3.7.2 似乎存在兼容性问题。当我切换到 3.7.15-M1 时,问题消失了。我不确定为什么。
关于java - Mac OSX Mavericks (10.9.1) 上 Xerial 的 JDBC SQLite 出现 SQLITE_NOTADB 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21837462/
我尝试使用包含已准备好的数据集的sqlite数据库构建Electron.js应用程序。我首先通过sqlite3命令创建了一个stock.db文件,然后以这种方式将其转储: sqlite3 stocks
我将 SQLCipher 配置为他们网站上的教程...我可以编译并运行该项目。但是 sqlite3_exec 在尝试执行语句时返回 SQLITE_NOTADB。 请在下面找到代码片段: =======
我从 iPhone 的 iTunes 备份中提取了 iOS 6 短信数据库。这是一个 sqlite3 数据库。 当我在终端中查询它时,它工作正常: $ sqlite3 sms.db sqlite> s
从 JDBC 读取 SQLite 数据库时出现以下错误:[SQLITE_NOTADB] 打开的文件不是数据库文件(文件已加密或不是数据库)。据我所知,这个数据库没有加密(见下面的标题)并且 sqlit
我是一名优秀的程序员,十分优秀!