java - 运行 Java SQLite JDBC 时出现 native 错误

标签 java sqlite jdbc raspberry-pi raspbian

我想在 Raspberry Pi vA 或 vB 上运行我的 Java 程序。我正在使用 SQLite JDBC 库,它应该支持 Raspi。当我启动 .jar 时,会弹出以下错误:

A fatal error has been detected by the Java Runtime Environment:

SIGILL (0x4) at pc=0xac507cb0, pid=5789, tid=3057054816

JRE version: Java(TM) SE Runtime Environment (8.0_65-b17) (build 1.8.0_65-b17)
Java VM: Java HotSpot(TM) Client VM (25.65-b01 mixed mode linux-arm )
Problematic frame:
C [sqlite-3.8.11.2-38a14bad-15c4-42f0-8c15-a19159eabd43-libsqlitejdbc.so+0x5cb0]

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

If you would like to submit a bug report, please visit:
http://bugreport.java.com/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.

Stack: [0xb6320000,0xb6370000], sp=0xb636d6f0, free space=309k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [sqlite-3.8.11.2-38a14bad-15c4-42f0-8c15-a19159eabd43-libsqlitejdbc.so+0x5cb0]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j java.lang.ClassLoader$NativeLibrary.load(Ljava/lang/String;Z)V+0
j java.lang.ClassLoader.loadLibrary0(Ljava/lang/Class;Ljava/io/File;)Z+328
j java.lang.ClassLoader.loadLibrary(Ljava/lang/Class;Ljava/lang/String;Z)V+48
j java.lang.Runtime.load0(Ljava/lang/Class;Ljava/lang/String;)V+57
j java.lang.System.load(Ljava/lang/String;)V+7
j org.sqlite.SQLiteJDBCLoader.loadNativeLibrary(Ljava/lang/String;Ljava/lang/String;)Z+29
j org.sqlite.SQLiteJDBCLoader.extractAndLoadLibraryFile(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z+308
j org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary()V+224
j org.sqlite.SQLiteJDBCLoader.initialize()Z+0
j org.sqlite.core.NativeDB.load()Z+19
j org.sqlite.core.CoreConnection.open(II)V+355
j org.sqlite.core.CoreConnection.(Ljava/lang/String;Ljava/lang/String;Ljava/util/Properties;)V+138
j org.sqlite.jdbc3.JDBC3Connection.(Ljava/lang/String;Ljava/lang/String;Ljava/util/Properties;)V+4
j org.sqlite.jdbc4.JDBC4Connection.(Ljava/lang/String;Ljava/lang/String;Ljava/util/Properties;)V+4
j org.sqlite.SQLiteConnection.(Ljava/lang/String;Ljava/lang/String;Ljava/util/Properties;)V+4
j org.sqlite.JDBC.createConnection(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;+24
j org.sqlite.JDBC.connect(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;+2
j java.sql.DriverManager.getConnection(Ljava/lang/String;Ljava/util/Properties;Ljava/lang/Class;)Ljava/sql/Connection;+171
j java.sql.DriverManager.getConnection(Ljava/lang/String;)Ljava/sql/Connection;+13

顺便说一下,该代码在 Windows 上运行良好。

我试图找到解决方案,但遇到了一个有一些相似之处的问题:https://github.com/xerial/sqlite-jdbc/issues/58 。 他们似乎找到了解决方案,但是固定的库文件不再可用。有人可以帮我吗?

最佳答案

XOWA 开发人员在此。 Github 线程已更新为最新答案,但我只是想在这里引用它,以防有人偶然发现这篇文章:https://github.com/xerial/sqlite-jdbc/issues/58#issuecomment-246115467

简而言之,XOWA arm 包中的 sqlite-jdbc jar 确实可以在 Raspberry Pi 上运行。 kwantuM 可能仍在使用旧的 sqlite-jdbc jar

我在下面摘录了更多内容。 kwantuM 或其他任何人:请随时告诉我是否应该添加/修改此评论。

谢谢。

<小时/>
I built a simple sample project to test yonisolos patch to get sqlite-jdbc working on Raspberry Pi.

Here were my steps to build the project:
* Used the sqlite-jdbc-3.8.11.2.jar in at /xowa/bin/any/java/jdbc/sqlite/sqlite-jdbc-3.8.11.2.jar 
* Built a Java project called piSqlite in Eclipse.
* Added sqlite-jdbc-3.8.11.2.jar to the Build Path
* Wrote sample code to create and insert into a SQLite database. See the source code at the bottom of this comment.
* Compiled the Java project into a jar file
* Also, all three files are available here: https://mega.nz/#fm/q55wDRTR

Here were my steps to test the project:
* Copied the piSqlite.jar to my "Raspberry Pi 2 Model B 1GB" device
* Opened up Terminal and ran the following <code>java -jar piSqlite.jar</code>. I got the following output:
```
No connection string specified. Using default of 'jdbc:sqlite:test.db'
Successfully opened database: jdbc:sqlite:test.db
Successfully created table called 'test_table'
Successfully inserted record into 'test_table'
Successfully selected data; test_id=1; test_string=abcde
Successfully closed connection. Exiting...
```

关于java - 运行 Java SQLite JDBC 时出现 native 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39160991/

相关文章:

java - 如何修复 java.lang.UnsupportedClassVersionError?

java - 如何从 Java 中的文件的每一行读取第三个值?

java - 将一个类定义为 Observable 和 Observer 两者

android - 从表中检索最后插入的 'n' 行

android - 有没有办法将缓存的响应提供给 Retrofit?

java - 使用 Java 获取 MySQL 输出的列数

java - 使用 setBounds() 创建 GUI

python-2.7 - Python sqlite3 Column1 val 的 Column 2 val 等于数字,并且 val 等于另一个数字

java - 如何在Mac上保持ssh连接?

java.sql.SQLException : Column count doesn't match value count at row 1 异常