Can't load spatial extension

Create issue
Issue #187 new
Piotr Synowiec created an issue

I tried to load libspatialite extension on my MacBook, failed with the message:

java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (dlsym(0x7fb410625280, sqlite3_spatialite_init): symbol not found)

I use soft versions:

spatialite installed from macports version: 4.2.0_1
JDK 1.8.0_45
sqlite-jdbc-3.8.10.1.jar

The error message doesn't indicate that db doesn't exists because it does.

I use the code

SQLiteConfig config = new SQLiteConfig();
config.enableLoadExtension(true);
Class.forName("org.sqlite.JDBC");
c    = DriverManager.getConnection("jdbc:sqlite:test.db", config.toProperties());
stmt = c.createStatement();
stmt.execute("SELECT load_extension('/opt/local/lib/libspatialite')");

any help is more than welcome

Comments (4)

  1. andrea antonello

    I have been having those issues also. They were due to 3 possible reasons:

    1) It works for me without full path

    stmt.execute("SELECT load_extension('libspatialite')");
    

    2) the native libs have to be in the LD_LIBRARY_PATH (linux ) or PATH (win) 3) the TMP folder in which the native sqlite lib is extracted, needs to be writable. In win for example once it picked me a non writable folder by default.

    That said, the error message you mention is always the same, no matter which error I get, so it is plain useless, if not misleading.

    Hope that helps.

  2. Andrew Psaltis

    Hi Piotr, Not sure if you are still having this issue. I was able to load it just fine using:

    stmt.execute("SELECT load_extension('mod_spatialite')");
    

    Hope that helps.

    Thanks, Andrew

  3. Log in to comment