Discussion:
Unable to make SQLite working with Java
Pierre Thibault
2010-11-28 08:10:01 UTC
Permalink
Hello,

I am unable to access an sqlite file in Groovy:

import java.sql.DriverManager
driverManager = Class.forName("java.sql.DriverManager").newInstance();
//Class.forName("org.sqlite.JDBC").newInstance(); // SQLite.JDBCDriver
org.sqlite.JDBC
print
DriverManager.getConnection("jdbc:sqlite:/media/pierreth-backup/work/web2py/applications/welcome/databases/storage.sqlite")

I have this error:

Unable to load sqlite_jni: java.lang.UnsatisfiedLinkError: no sqlite_jni in
java.library.path
Caught: java.sql.SQLException: java.lang.UnsatisfiedLinkError:
SQLite.Database.internal_init()V

But my class path is OK:

/usr/local/share/java/sqlite.jar:/opt/java/lib/sqlitejdbc-v056.jar

and java.library.path is /usr/local/lib where I have libsqlite_jni.so.

Any idea?
--
A+

-------------
Pierre
Pierre Thibault
2010-11-29 01:18:35 UTC
Permalink
Hello,

I found that copying the library, libsqlite_jna.so and libsqlite_jna.la,
from /usr/local/lib to /usr/lib solve the problem. I don't why but it works.
:-)
Post by Pierre Thibault
Hello,
import java.sql.DriverManager
driverManager = Class.forName("java.sql.DriverManager").newInstance();
//Class.forName("org.sqlite.JDBC").newInstance(); // SQLite.JDBCDriver
org.sqlite.JDBC
print
DriverManager.getConnection("jdbc:sqlite:/media/pierreth-backup/work/web2py/applications/welcome/databases/storage.sqlite")
Unable to load sqlite_jni: java.lang.UnsatisfiedLinkError: no sqlite_jni in
java.library.path
SQLite.Database.internal_init()V
/usr/local/share/java/sqlite.jar:/opt/java/lib/sqlitejdbc-v056.jar
and java.library.path is /usr/local/lib where I have libsqlite_jni.so.
Any idea?
--
A+
-------------
Pierre
--
A+

-------------
Pierre
Timothy A. Sawyer
2010-11-29 03:13:41 UTC
Permalink
Check the LD_LIBRARY_PATH variable and make sure that /usr/local/lib is in the path.
------Original Message------
From: Pierre Thibault
Sender: sqlite-users-bounces-CzDROfG0BjIdnm+***@public.gmane.org
To: sqlite-users-CzDROfG0BjIdnm+***@public.gmane.org
ReplyTo: General Discussion of SQLite Database
Subject: Re: [sqlite] Unable to make SQLite working with Java
Sent: Nov 28, 2010 20:18

Hello,

I found that copying the library, libsqlite_jna.so and libsqlite_jna.la,
from /usr/local/lib to /usr/lib solve the problem. I don't why but it works.
:-)
Post by Pierre Thibault
Hello,
import java.sql.DriverManager
driverManager = Class.forName("java.sql.DriverManager").newInstance();
//Class.forName("org.sqlite.JDBC").newInstance(); // SQLite.JDBCDriver
org.sqlite.JDBC
print
DriverManager.getConnection("jdbc:sqlite:/media/pierreth-backup/work/web2py/applications/welcome/databases/storage.sqlite")
Unable to load sqlite_jni: java.lang.UnsatisfiedLinkError: no sqlite_jni in
java.library.path
SQLite.Database.internal_init()V
/usr/local/share/java/sqlite.jar:/opt/java/lib/sqlitejdbc-v056.jar
and java.library.path is /usr/local/lib where I have libsqlite_jni.so.
Any idea?
--
A+
-------------
Pierre
--
A+

-------------
Pierre
_______________________________________________
sqlite-users mailing list
sqlite-users-CzDROfG0BjIdnm+***@public.gmane.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


** Sent from my mobile device with the tiny keys **

Timothy A. Sawyer, CISSP
Managing Director
MBD Consulting, LLC
55 Madison Av., Suite 400
Morristown, NJ 07960
Phone: (973) 285-3261 | Fax: (973) 538-0503
Web: http://www.mybowlingdiary.com
Email: tsawyer-***@public.gmane.org
Pierre Thibault
2010-11-29 04:31:28 UTC
Permalink
Post by Timothy A. Sawyer
Check the LD_LIBRARY_PATH variable and make sure that /usr/local/lib is in the path.
LD_LIBRARY_PATH is a awful solution. It is not working any better when I do
export LD_LIBRARY_PATH=/usr/local/lib.

Putting /usr/local/lib in the Java library path does not help either.

But copying to /usr/lib makes everything OK. It would be nice to know why.
--
A+

-------------
Pierre
Timothy A. Sawyer
2010-11-29 03:16:48 UTC
Permalink
Not knowing much about your specific environment, wouldn't it be easier to just do what you need to do in Java without having to use C?
------Original Message------
From: Pierre Thibault
Sender: sqlite-users-bounces-CzDROfG0BjIdnm+***@public.gmane.org
To: sqlite-users-CzDROfG0BjIdnm+***@public.gmane.org
ReplyTo: General Discussion of SQLite Database
Subject: Re: [sqlite] Unable to make SQLite working with Java
Sent: Nov 28, 2010 20:18

Hello,

I found that copying the library, libsqlite_jna.so and libsqlite_jna.la,
from /usr/local/lib to /usr/lib solve the problem. I don't why but it works.
:-)
Post by Pierre Thibault
Hello,
import java.sql.DriverManager
driverManager = Class.forName("java.sql.DriverManager").newInstance();
//Class.forName("org.sqlite.JDBC").newInstance(); // SQLite.JDBCDriver
org.sqlite.JDBC
print
DriverManager.getConnection("jdbc:sqlite:/media/pierreth-backup/work/web2py/applications/welcome/databases/storage.sqlite")
Unable to load sqlite_jni: java.lang.UnsatisfiedLinkError: no sqlite_jni in
java.library.path
SQLite.Database.internal_init()V
/usr/local/share/java/sqlite.jar:/opt/java/lib/sqlitejdbc-v056.jar
and java.library.path is /usr/local/lib where I have libsqlite_jni.so.
Any idea?
--
A+
-------------
Pierre
--
A+

-------------
Pierre
_______________________________________________
sqlite-users mailing list
sqlite-users-CzDROfG0BjIdnm+***@public.gmane.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


** Sent from my mobile device with the tiny keys **

Timothy A. Sawyer, CISSP
Managing Director
MBD Consulting, LLC
55 Madison Av., Suite 400
Morristown, NJ 07960
Phone: (973) 285-3261 | Fax: (973) 538-0503
Web: http://www.mybowlingdiary.com
Email: tsawyer-***@public.gmane.org
Pierre Thibault
2010-11-29 04:36:13 UTC
Permalink
Post by Timothy A. Sawyer
Not knowing much about your specific environment, wouldn't it be easier to
just do what you need to do in Java without having to use C?
The point of all this is trying to use web2py, a Python web framework, with
the Jython implementation of Python on the Java platform. SQLite is the
default database manager of web2py so I want to make it work with Java
first.

I was able to make my Groovy script work but another version of the same
script written in Jython still does not work. I really don't know why. This
is where I am now.
--
A+

-------------
Pierre
Pierre Thibault
2010-11-29 05:02:20 UTC
Permalink
I am able to do System.loadLibrary("sqlite_jni") in my Jython script so it
seems the problem is more with Jython itself. I am progressing.

I have this error instead:

java.sql.SQLException: java.sql.SQLException: No suitable driver found for
jdbc:sqlite:/home/pierreth/work/web2py/applications/welcome/databases/storage.sqlite
--
A+

-------------
Pierre
Pierre Thibault
2010-11-29 05:34:58 UTC
Permalink
OK,

I found the solution for Jython. I must list my jars in CLASSPATH and not in
JYTHONPATH. I don't have to copy my native library to /usr/lib if I point to
them using the Java system property java.library.path.

:-)
Post by Pierre Thibault
I am able to do System.loadLibrary("sqlite_jni") in my Jython script so it
seems the problem is more with Jython itself. I am progressing.
java.sql.SQLException: java.sql.SQLException: No suitable driver found for
jdbc:sqlite:/home/pierreth/work/web2py/applications/welcome/databases/storage.sqlite
--
A+
-------------
Pierre
--
A+

-------------
Pierre
Loading...