Fixed SQLite driver loading
This commit is contained in:
parent
e2561ca672
commit
e1f520911f
|
@ -9,8 +9,10 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
|
||||||
org.eclipse.equinox.util;bundle-version="1.0.500",
|
org.eclipse.equinox.util;bundle-version="1.0.500",
|
||||||
org.eclipse.equinox.ds;bundle-version="1.4.200",
|
org.eclipse.equinox.ds;bundle-version="1.4.200",
|
||||||
org.eclipse.osgi.services;bundle-version="3.4.0"
|
org.eclipse.osgi.services;bundle-version="3.4.0"
|
||||||
Bundle-ClassPath: .,
|
Bundle-ClassPath: .,sqlite-jdbc-3.8.7.jar
|
||||||
sqlite-jdbc-3.8.7.jar
|
|
||||||
Service-Component: OSGI-INF/component.xml
|
Service-Component: OSGI-INF/component.xml
|
||||||
Export-Package: com.minres.scviewer.database.sqlite
|
Export-Package: com.minres.scviewer.database.sqlite
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
|
Embed-Dependency: sqlite-jdbc
|
||||||
|
Embedded-Artifacts: sqlite-jdbc-3.8.7.jar;g="org.xerial";
|
||||||
|
a="sqlite-jdbc";v="3.8.7"
|
||||||
|
|
|
@ -1,19 +1,6 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>com.minres.scviewer.database.sqlite</artifactId>
|
<artifactId>com.minres.scviewer.database.sqlite</artifactId>
|
||||||
<build>
|
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.7</source>
|
|
||||||
<target>1.7</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
|
@ -21,4 +8,11 @@
|
||||||
<relativePath>../com.minres.scviewer.parent</relativePath>
|
<relativePath>../com.minres.scviewer.parent</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xerial</groupId>
|
||||||
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
|
<version>3.8.7</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.minres.scviewer.database.sqlite.db;
|
package com.minres.scviewer.database.sqlite.db;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
@ -18,12 +20,27 @@ import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.sqlite.JDBC;
|
||||||
|
|
||||||
public class SQLiteDatabase implements IDatabase {
|
public class SQLiteDatabase implements IDatabase {
|
||||||
|
|
||||||
protected String dbFileName;
|
protected String dbFileName;
|
||||||
|
|
||||||
protected HashMap<String, Object> props;
|
protected HashMap<String, Object> props;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
URL dbUrl = SQLiteDatabase.class.getResource("/sqlite-jdbc-3.8.7.jar");
|
||||||
|
ClassLoader loader = URLClassLoader.newInstance(
|
||||||
|
new URL[] { dbUrl },
|
||||||
|
SQLiteDatabase.class.getClassLoader()
|
||||||
|
);
|
||||||
|
Class.forName("org.sqlite.JDBC", true, loader);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SQLiteDatabase(String dbFileName) {
|
public SQLiteDatabase(String dbFileName) {
|
||||||
super();
|
super();
|
||||||
this.dbFileName = dbFileName;
|
this.dbFileName = dbFileName;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<module>../com.minres.scviewer.database.vcd</module>
|
<module>../com.minres.scviewer.database.vcd</module>
|
||||||
<module>../com.minres.scviewer.feature</module>
|
<module>../com.minres.scviewer.feature</module>
|
||||||
<module>../com.minres.scviewer.ui</module>
|
<module>../com.minres.scviewer.ui</module>
|
||||||
|
|
||||||
<module>../com.minres.scviewer.updateSite</module>
|
<module>../com.minres.scviewer.updateSite</module>
|
||||||
<module>../com.minres.scviewer.database.test</module>
|
<module>../com.minres.scviewer.database.test</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
Loading…
Reference in New Issue