在 Raspberry pi 上打开连接 SQLite 时出错 [英] Error opening connection SQLite on Raspberry pi

查看:30
本文介绍了在 Raspberry pi 上打开连接 SQLite 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:我只是检查了我使用的最新 JDBC jar,但它缺少映射/Linux/arm/libsqlitejdbc.so,通过从某个地方下载此文件可以解决此问题吗?到处都找不到.

Update: I just check the latest JDBC jar which I use, and it's missing the map /Linux/arm/libsqlitejdbc.so, Would this problem be fixed by downloading this file from somewhere? Can't find it anywhere.

问题似乎是这个,但是我不知道如何解决这个问题.

Problem seems to be this, however I don't know how to fix this.

Caused by: java.lang.Exception: Error loading native library: /org/sqlite/native/Linux/arm/libsqlitejdbc.so

我正在尝试在我的树莓派上使用 SQLite 数据库.但是我无法让它工作.我得到下面发布的输出.我正在使用 JDBC 驱动程序.该代码在我的主计算机上运行良好.我到处搜索,但找不到解决方案.如果重要的话,我将我的代码打包到一个 Jar 文件中.

I'm trying to use a SQLite database on my raspberry pi. However I can't get it to work. I get the output posted below. I'm using the JDBC driver. The code works fine on my main computer. I have searched everywhere but can't find a solution. I packed my code into a Jar file if that matters.

相关代码:

     private final String dbLocation = "jdbc:sqlite:" + System.getProperty("user.home") + "/ServerSQLite.db";

    public SQLServer() throws ClassNotFoundException {
        System.out.println("DB location: " + dbLocation);
        Connection connection = null;
        Class.forName("org.sqlite.JDBC");
        try {

            // create a database connection
            connection = DriverManager.getConnection(dbLocation);

输出:

DB location: jdbc:sqlite:/usr/share/tomcat7/ServerSQLite.db
Error opening connection

硬编码位置的相同问题,应该具有读写权限:

same problem with hardcoded location which should have both read and write permission:

jdbc:sqlite:/home/pi/ServerSQLite.db
Error opening connection

感谢我能得到的任何帮助:)

Thankful for any help I can get :)

编辑 2:以为我打印了堆栈跟踪,但这里没有:

Edit 2: Thought I printed stack trace, but didn't here it is:

java.sql.SQLException: Error opening connection
    ...Lots of exception
Caused by: java.lang.Exception: Error loading native library: /org/sqlite/native/Linux/arm/libsqlitejdbc.so
    at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:241)
...
    at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:175)
    ... 29 more
Error opening connection

问题似乎是由以下原因引起的:

Problem seems to be Caused by:

java.lang.Exception: Error loading native library: /org/sqlite/native/Linux/arm/libsqlitejdbc.so

推荐答案

您需要下载 SQLite 库的 arm 版本.我发现只有一个地方可以得到它:https://bitbucket.org/xerial/sqlite-jdbc/issue/79/compile-for-arm

You need to download an arm build of SQLite library. I found only one place where you can get it: https://bitbucket.org/xerial/sqlite-jdbc/issue/79/compile-for-arm

这篇关于在 Raspberry pi 上打开连接 SQLite 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆