4
import java.util.Properties;
6
public class JDBCDriver implements java.sql.Driver {
8
public static final int MAJORVERSION = 1;
10
public static boolean sharedCache = false;
12
public static String vfs = null;
14
private static java.lang.reflect.Constructor makeConn = null;
16
protected Connection conn;
20
Class connClass = null;
21
Class args[] = new Class[5];
22
args[0] = Class.forName("java.lang.String");
27
String jvers = java.lang.System.getProperty("java.version");
29
if (jvers == null || jvers.startsWith("1.0")) {
30
throw new java.lang.Exception("unsupported java version");
31
} else if (jvers.startsWith("1.1")) {
32
cvers = "SQLite.JDBC1.JDBCConnection";
33
} else if (jvers.startsWith("1.2") || jvers.startsWith("1.3")) {
34
cvers = "SQLite.JDBC2.JDBCConnection";
35
} else if (jvers.startsWith("1.4")) {
36
cvers = "SQLite.JDBC2x.JDBCConnection";
37
} else if (jvers.startsWith("1.5")) {
38
cvers = "SQLite.JDBC2y.JDBCConnection";
41
} catch (java.lang.Exception e) {
42
cvers = "SQLite.JDBC2x.JDBCConnection";
45
cvers = "SQLite.JDBC2z.JDBCConnection";
48
} catch (java.lang.Exception e) {
49
cvers = "SQLite.JDBC2y.JDBCConnection";
52
} catch (java.lang.Exception ee) {
53
cvers = "SQLite.JDBC2x.JDBCConnection";
57
connClass = Class.forName(cvers);
58
makeConn = connClass.getConstructor(args);
59
java.sql.DriverManager.registerDriver(new JDBCDriver());
62
java.lang.System.getProperty("SQLite.sharedcache");
63
if (shcache != null &&
64
(shcache.startsWith("y") || shcache.startsWith("Y"))) {
65
sharedCache = SQLite.Database._enable_shared_cache(true);
67
} catch (java.lang.Exception e) {
71
java.lang.System.getProperty("SQLite.vfs");
75
} catch (java.lang.Exception e) {
77
} catch (java.lang.Exception e) {
78
System.err.println(e);
85
public boolean acceptsURL(String url) throws SQLException {
86
return url.startsWith("sqlite:/") ||
87
url.startsWith("jdbc:sqlite:/");
90
public Connection connect(String url, Properties info)
92
if (!acceptsURL(url)) {
95
Object args[] = new Object[5];
98
args[1] = info.getProperty("encoding");
99
args[2] = info.getProperty("password");
100
args[3] = info.getProperty("daterepr");
101
args[4] = info.getProperty("vfs");
103
if (args[1] == null) {
104
args[1] = java.lang.System.getProperty("SQLite.encoding");
106
if (args[4] == null) {
110
conn = (Connection) makeConn.newInstance(args);
111
} catch (java.lang.reflect.InvocationTargetException ie) {
112
throw new SQLException(ie.getTargetException().toString());
113
} catch (java.lang.Exception e) {
114
throw new SQLException(e.toString());
119
public int getMajorVersion() {
123
public int getMinorVersion() {
124
return Constants.drv_minor;
127
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
128
throws SQLException {
129
DriverPropertyInfo p[] = new DriverPropertyInfo[4];
130
DriverPropertyInfo pp = new DriverPropertyInfo("encoding", "");
132
pp = new DriverPropertyInfo("password", "");
134
pp = new DriverPropertyInfo("daterepr", "normal");
136
pp = new DriverPropertyInfo("vfs", vfs);
141
public boolean jdbcCompliant() {