我在加载 Java 中的空间扩展以读取 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)
有什么我想念的吗。我已经安装sqlite3
并spatialite
使用了 Homebrew,这就是spatialite
我正在尝试使用的版本。