在MacOS上将Spacelite与xerial / sqlite-jdbc一起使用

问题描述

在加载Java中的spacespaceite扩展以读取GeoPackage时遇到一些问题,我有以下代码段:

import org.sqlite.sqliteConfig;

import java.net.URI;
import java.net.URISyntaxException;
import java.sql.Connection;
import java.sql.sqlException;
import java.sql.Statement;

public class DatabaseTest {

    public static void main(String[] args) throws sqlException,URISyntaxException {
        URI databaseURI = DatabaseTest.class.getResource("/database.gpkg").toURI();
        String databaseURL = String.format("jdbc:sqlite:%s",databaseURI);
        sqliteConfig config = new sqliteConfig();
        config.enableLoadExtension(true);
        Connection connection = config.createConnection(databaseURL);

        Statement statement = connection.createStatement();
        boolean success = statement.execute("SELECT load_extension('mod_spatialite')");
        System.out.println(success);
        statement.close();
        connection.close();
    }

}

这将导致[sqlITE_ERROR] sql error or missing database (dlopen(mod_spatialite.dylib,10): image not found)

如果我更改为

boolean success = statement.execute("SELECT load_extension('/usr/local/lib/mod_spatialite')");

结果为Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

有什么我想念的吗?我已经使用Homebrew安装了sqlite3spatialite,而这就是我要使用的spatialite的版本。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)