diff --git a/pom.xml b/pom.xml
index 71d123000..bcb9443dd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -700,10 +700,22 @@
org.xerial:sqlite-jdbc:jar:*
- native/**
- org/ibex/**
org/sqlite/**
+
+
+
+ org/sqlite/native/FreeBSD/**
+ org/sqlite/native/Linux-Android/**
+ org/sqlite/native/Linux/ppc64/*
+ org/sqlite/native/Linux/arm/*
+ org/sqlite/native/Linux/armv6/*
+ org/sqlite/native/Linux/armv7/*
+ org/sqlite/native/Linux/x86/*
+ org/sqlite/native/Linux-Musl/x86/*
+ org/sqlite/native/Windows/x86/*
+ org/sqlite/native/Windows/armv7/*
+
org.apache.commons:commons-io:jar:*
diff --git a/src/main/java/com/laytonsmith/database/SQLiteProfile.java b/src/main/java/com/laytonsmith/database/SQLiteProfile.java
index 6fedba9bc..ae0f456ae 100644
--- a/src/main/java/com/laytonsmith/database/SQLiteProfile.java
+++ b/src/main/java/com/laytonsmith/database/SQLiteProfile.java
@@ -2,6 +2,9 @@
import com.laytonsmith.core.Profiles;
import com.laytonsmith.core.MethodScriptFileLocations;
+import org.sqlite.SQLiteJDBCLoader;
+import org.sqlite.util.OSInfo;
+
import java.io.File;
import java.sql.SQLException;
import java.util.Map;
@@ -37,6 +40,22 @@ public String getConnectionString() throws SQLException {
} catch (ClassNotFoundException ex) {
throw new SQLException("Cannot load SQLite. Check your installation and try again");
}
+ // Set native library override path if not already set. (e.g. -Dorg.sqlite.lib.path="/path/to/lib")
+ if(System.getProperty("org.sqlite.lib.path") == null) {
+ System.setProperty("org.sqlite.lib.path", new File(MethodScriptFileLocations.getDefault().getConfigDirectory(),
+ "sqlite/native/" + OSInfo.getNativeLibFolderPathForCurrentOS()).getAbsolutePath());
+ }
+ try {
+ // Load native library before connection to detect when the library is missing.
+ // This is done in SQLiteDataSource as well.
+ SQLiteJDBCLoader.initialize();
+ } catch (Exception ex) {
+ throw new SQLException("Failed to load a native sqlite library for your platform."
+ + " You can download the library file from"
+ + " https://github.com/xerial/sqlite-jdbc/tree/master/src/main/resources/org/sqlite/native/"
+ + OSInfo.getNativeLibFolderPathForCurrentOS() + " and place it into "
+ + System.getProperty("org.sqlite.lib.path"));
+ }
return "jdbc:sqlite:" + getFile();
}
diff --git a/src/main/java/com/laytonsmith/persistence/SQLiteDataSource.java b/src/main/java/com/laytonsmith/persistence/SQLiteDataSource.java
index d27699e3c..6ed04b014 100644
--- a/src/main/java/com/laytonsmith/persistence/SQLiteDataSource.java
+++ b/src/main/java/com/laytonsmith/persistence/SQLiteDataSource.java
@@ -5,9 +5,14 @@
import com.laytonsmith.annotations.datasource;
import com.laytonsmith.core.MSLog;
import com.laytonsmith.core.MSVersion;
+import com.laytonsmith.core.MethodScriptFileLocations;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.persistence.io.ConnectionMixin;
import com.laytonsmith.persistence.io.ConnectionMixinFactory;
+import org.sqlite.SQLiteJDBCLoader;
+import org.sqlite.util.OSInfo;
+
+import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.sql.DriverManager;
@@ -61,6 +66,22 @@ public SQLiteDataSource(URI uri, ConnectionMixinFactory.ConnectionMixinOptions o
mixin = getConnectionMixin();
try {
Class.forName(org.sqlite.JDBC.class.getName());
+ // Set native library override path if not already set. (e.g. -Dorg.sqlite.lib.path="/path/to/lib")
+ if(System.getProperty("org.sqlite.lib.path") == null) {
+ System.setProperty("org.sqlite.lib.path", new File(MethodScriptFileLocations.getDefault().getConfigDirectory(),
+ "sqlite/native/" + OSInfo.getNativeLibFolderPathForCurrentOS()).getAbsolutePath());
+ }
+ try {
+ // Load native library before connection to detect when the library is missing.
+ // This is done in SQLiteProfile as well.
+ SQLiteJDBCLoader.initialize();
+ } catch (Exception ex) {
+ throw new DataSourceException("Failed to load a native sqlite library for your platform."
+ + " You can download the library file from"
+ + " https://github.com/xerial/sqlite-jdbc/tree/master/src/main/resources/org/sqlite/native/"
+ + OSInfo.getNativeLibFolderPathForCurrentOS() + " and place it into "
+ + System.getProperty("org.sqlite.lib.path"));
+ }
path = mixin.getPath();
connect();
long startTime = System.currentTimeMillis();
@@ -88,7 +109,7 @@ public SQLiteDataSource(URI uri, ConnectionMixinFactory.ConnectionMixinOptions o
}
}
} catch (ClassNotFoundException | UnsupportedOperationException | IOException | SQLException ex) {
- throw new DataSourceException("An error occured while setting up a connection to the SQLite database", ex);
+ throw new DataSourceException("An error occurred while setting up a connection to the SQLite database", ex);
} finally {
if(DO_DISCONNECTS) {
disconnect();