4

I have created small code of sqlite database in java.

Below is the code for connection with database,

Class.forName("org.sqlite.JDBC");

objConnection=DriverManager.getConnection("jdbc:sqlite:/etc/javaData/Test.db");

In this code the exception thrown in second line for getConnection(). I am trying this code on Raspberry pi. How to fix the exceptionrelated to this

Exception

SQLITE addDeviceInfo()-[SQLITE] SQL Exception occured. RetryCount:1 (MAX Retry: 2) ErrorCode: 27154 Exception Message: Error opening connection Stack Trace: java.sql.SQLException: Error opening connection
  at org.sqlite.core.CoreConnection.open(CoreConnection.java:140)
  at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:66)
  at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:21)
  at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:23)
  at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
  at org.sqlite.JDBC.createConnection(JDBC.java:114)
  at org.sqlite.JDBC.connect(JDBC.java:88)
  at java.sql.DriverManager.getConnection(DriverManager.java:571)
  at java.sql.DriverManager.getConnection(DriverManager.java:215)
  at kmbt.DCA.SQLite.DCASQLiteUtility.getSQliteConnection(DCASQLiteUtility.java:152)
  at kmbt.DCA.SQLite.ManagedDeviceSetting.SQLite_ManagedDeviceSettingManager.addDeviceInfo(SQLite_ManagedDeviceSettingManager.java:981)
  at kmbt.DCA.DCAChildProcessMng.InitManagedDeviceInfo(DCAChildProcessMng.java:5726)
  at kmbt.DCA.DCAChildProcessMng.InitSQLite(DCAChildProcessMng.java:4387)
  at kmbt.DCA.DCAChildProcessMng.start(DCAChildProcessMng.java:365)
  at kmbt.DCA.DCAChildProcess.main(DCAChildProcess.java:23)
 Caused by: java.lang.Exception: Error loading native library: /org/sqlite/native/Linux/arm/libsqlitejdbc.so
  at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:243)  at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:65)
  at org.sqlite.core.NativeDB.load(NativeDB.java:53)
  at org.sqlite.core.CoreConnection.open(CoreConnection.java:136)
  ... 14 more
1
  • Did you manage to solve this? Commented Apr 14, 2015 at 13:54

2 Answers 2

1

Your code seems correct and the exception thrown seems don't have nothing to do with some library's problem. The only thing that sound me a little bit strange, is that you put your database in /etc folder. First of all it is not very correct, because the /etc folder is used to store config file and not data. In addition to this, maybe there could be some kind of issue with r/w folder's permissions. Try to move your database to your home directory or to other any directory owned by your user and not from root.

Hope this will be usefull for you.

-- EDIT --

Ok, the problem is that you have downloaded the wrong library:

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

You have to use the ARM build of the sqlite library. Try to take a look at this: Error opening connection SQLite on Raspberry pi and this: Sqlite4java on Raspberry Pi

Sign up to request clarification or add additional context in comments.

13 Comments

Database moved to another directory, now also it shows same exception
Could you add to your question the full stack trace given?
This is not whole stack trace, some part skipped from this.
Ok, can you post the complete one?
Complete exception posted
|
1

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

Looking into sqlite-jdbc-3.8.6.jar I found that /org/sqlite/native/Linux/ contains no arm folder -> sqlite is not compiled for arm.

With these changes I've managed to build on the pi: https://bitbucket.org/kidmose/sqlite-jdbc/commits/cb7a7ef62c034938e8ecb737b148e5c80877c083

pi@raspberry ~/sqlite-jdbc $ export JAVA_HOME=/usr/lib/jvm/jdk-7-oracle-armhf/
pi@raspberry ~/sqlite-jdbc $ chmod 755 ./amalgamation_version.sh
pi@raspberry ~/sqlite-jdbc $ make

Replacing the old jar with the newly built one solved my problem.

All credit goes to: https://pidome.wordpress.com/2013/10/01/java-goes-hard-on-the-raspberry-pi-so-does-pidome/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.