Repository: xerial/sqlite-jdbc
Issue: Usage of sqlite-jdbc together with the relocation feature of the Maven shade plugin

I would like to use the sqlite in a project where I have to use the relocation feature of the Maven shade plugin to avoid clashes with different versions of the same library being loaded. The Maven shade plugin can relocate all Java classes to a different package name (e.g., org.sqlite to test.org.sqlite). 

Unfortunately, sqlite-jdbc seems to load some of its classes dynamically at runtime in such a way that it is impossible for the Maven shade plugin to adjust the references accordingly. Therefore, all projects that use sqlilte, for example [cqengine](https://github.com/npgall/cqengine/issues/86), cannot be "shaded" entirely.

I created a small standalone test that demonstrates the issue. The test runs the example code of sqlite-jdbc. The JUnit test runs successfull, but when executing the shaded artifact: sqlite[...]-shaded.jar I get the following error:

> java -jar target/sqlite-shade-test-0.0.1-SNAPSHOT-shaded.jar
> java.sql.SQLException: No suitable driver found for jdbc:sqlite:C:\\Users[...]AppData\\Loca\\Temp\\test_8871362628708427569.db
>        at java.sql.DriverManager.getConnection(Unknown Source)
>        at java.sql.DriverManager.getConnection(Unknown Source)
>        at test.SQLite.open(SQLite.java:21)
>        at test.SQLite.main(SQLite.java:28)`

I tried to load the correct shaded driver with:

```
        try {
            Class.forName("test.org.sqlite.JDBC");
        } catch (ClassNotFoundException e) {
        }
```

but that leads to a ClassNotFoundException.

Would it be possible to support this use case? 
[sqlite-shade-test.zip](https://github.com/xerial/sqlite-jdbc/files/454772/sqlite-shade-test.zip)


Changed files:
src/main/java/org/sqlite/SQLiteJDBCLoader.java

diff --git a/src/main/java/org/sqlite/SQLiteJDBCLoader.java b/src/main/java/org/sqlite/SQLiteJDBCLoader.java
index 1878e04..fc06a88 100644
--- a/src/main/java/org/sqlite/SQLiteJDBCLoader.java
+++ b/src/main/java/org/sqlite/SQLiteJDBCLoader.java
@@ -19,7 +19,7 @@
 // SQLite.java
 // Since: 2007/05/10
 //
-// $URL$ 
+// $URL$
 // $Author$
 //--------------------------------------
 package org.sqlite;
@@ -308,7 +308,8 @@ public class SQLiteJDBCLoader {
         }
 
         // Load the os-dependent library from the jar file
-        sqliteNativeLibraryPath = "/org/sqlite/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
+        String packagePath = SQLiteJDBCLoader.class.getPackage().getName().replaceAll("\\\\.", "/");
+        sqliteNativeLibraryPath = String.format("/%s/native/%s", packagePath, OSInfo.getNativeLibFolderPathForCurrentOS());
         boolean hasNativeLib = hasResource(sqliteNativeLibraryPath + "/" + sqliteNativeLibraryName);
 
 
@@ -325,12 +326,12 @@ public class SQLiteJDBCLoader {
 
         if(!hasNativeLib) {
             extracted = false;
-            throw new Exception(String.format("No native library is found for os.name=%s and os.arch=%s", OSInfo.getOSName(), OSInfo.getArchName()));
+            throw new Exception(String.format("No native library is found for os.name=%s and os.arch=%s. path=%s", OSInfo.getOSName(), OSInfo.getArchName(), sqliteNativeLibraryPath));
         }
 
         // temporary library folder
         String tempFolder = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
-        // Try extracting the library from jar 
+        // Try extracting the library from jar
         if(extractAndLoadLibraryFile(sqliteNativeLibraryPath, sqliteNativeLibraryName, tempFolder)) {
             extracted = true;
             return;