sqlite-jdbc cleanup of native libs

512 views
Skip to first unread message

Ryan Twitchell

unread,
Nov 29, 2010, 12:55:26 AM11/29/10
to Xerial
Hi,

Long explanation summed up:
Should the SQLite driver be cleaning up the native libs it extracts?
And if so, does it depend on the value of java.io.tmpdir at cleanup
time, or does it remember where the native libs are?


I have an issue with sqlite-jdbc's extraction of native libs. On a
Linux system where /tmp is mounted as noexec, linking to the extracted
native lib fails (see below), and the driver (quite gracefully) falls
back to the pure Java version. This is fine, and I know that this is
an environment problem, not a problem with the driver.

For Unix-like systems, I am just going to set java.io.tmpdir to /var/
tmp while loading the driver / opening connections, and restore it
afterwards. Not sure if this is the best approach, but I have no idea
how to inspect mount options from Java.

Running the sample file, with DriverManager logging to stdout:

DriverManager.getConnection("jdbc:sqlite:sample.db")
trying
driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@2e471e30]
*Driver.connect (jdbc:sqlite:sample.db)
trying driver[className=org.sqlite.JDBC,org.sqlite.JDBC@39d8957f]
java.lang.UnsatisfiedLinkError: /tmp/sqlite-3.7.2-libsqlitejdbc.so: /
tmp/sqlite-3.7.2-libsqlitejdbc.so: failed to map segment from shared
object: Operation not permitted
getConnection returning
driver[className=org.sqlite.JDBC,org.sqlite.JDBC@39d8957f]

Thanks,
Ryan

Taro L. Saito

unread,
Nov 29, 2010, 3:39:50 AM11/29/10
to xer...@googlegroups.com
Hi Ryan,

For saving the storage space, sqlite-jdbc extracts a native library
using a same file name across multiple programs using sqlite-jdbc driver.

I think setting an alternative directory to java.io.tmpdir, to which
native libraries are extracted, is the best practice,
because deleting the native library file might causes an error when
other programs using sqlite-jdbc of the same version exist.

Adding an option to sqlite-jdbc to use a user-specified native library
file/directory name is possible.
And calling File.deleteOnExit() method to delete the native library
files is an easy way to do what you said.

Regards,
--
Taro L. Saito
<l...@xerial.org>
University of Tokyo
http://www.xerial.org/leo
Tel. +81-47-136-3985 (63985)

Reply all
Reply to author
Forward
0 new messages