Loading spatialite extension

92 views
Skip to first unread message

andrea antonello

unread,
Jun 30, 2015, 5:21:36 AM6/30/15
to sqlit...@googlegroups.com
Hi, I am trying to to test the library with the spatialite extensions for sqlite.

I would like to have this work on windows, since it is the most tricky system when it comes to native bindings.

I am trying to run a database creation, during which the spatialite lib is supposed to load a pile of geographic information.

I do this like:
        
        String nativeSpatialiteLib = "path_to/mod_spatialite.dll";
        String nativeSqliteLib = "path_to/com/almworks/sqlite4java/sqlite4java-win32-x64/1.0.392/";
        SQLite.setLibraryPath(nativeSqliteLib);

        conn = new SQLiteConnection(dbFile);
        conn.open(true);
        
        conn.setExtensionLoadingEnabled(true);
        File ext = new File(nativeSpatialiteLib);
        conn.loadExtension(ext);
        String sql = "SELECT InitSpatialMetadata()";
        conn.exec(sql);

        conn.dispose();

While the sqlite libs are properly loaded, it fails in:
        conn.loadExtension(ext);

Telling me:
Exception in thread "main" com.almworks.sqlite4java.SQLiteException: [1] DB[1] loadExtension() Impossibile trovare la procedura specificata.

which means as much as: impossible to find the specified method.
I am not sure if I am loading the mod_spatialite properly.
As a sidenote, in the xerial jdbc the lib was properly loaded with: stmt.execute("SELECT load_extension('mod_spatialite')");
after putting the native spatialite ibs in the path.

Thanks for any hint.

Cheers,
Andrea






ser...@almworks.com

unread,
Aug 9, 2015, 3:29:32 PM8/9/15
to sqlite4java
Hi Andrea, 

Did you manage to solve this? It seems that you tried to do everything correctly.

I finally got some time to try this on a Windows machine and reproduced the problem. However, when I try to load the extension through SQL - SELECT load_extension('mod_spatialite') - as you suggested, it works in sqlite4java too. Hope you've found this workaround.

I'll file this as a bug - it should be working the other way too.

Kind regards,
Igor
Reply all
Reply to author
Forward
0 new messages