File: JDBC.java

package info (click to toggle)
db5.3 5.3.28%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 158,500 kB
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,264; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,077; javascript: 1,998; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (144 lines) | stat: -rw-r--r-- 3,923 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package SQLite;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public abstract class JDBC {

    public static final int MAJORVERSION = 1;

    public static boolean sharedCache = false;

    public static String vfs = null;

    private static java.lang.reflect.Constructor makeConn = null;

    static {
	try {
	    Class connClass = null;
	    Class args[] = new Class[5];
	    args[0] = Class.forName("java.lang.String");
	    args[1] = args[0];
	    args[2] = args[0];
	    args[3] = args[0];
	    args[4] = args[0];
	    String jvers = java.lang.System.getProperty("java.version");
	    String vmvers = java.lang.System.getProperty("java.vm.name");
	    String cvers;
	    if (vmvers != null && "CVM".equalsIgnoreCase(vmvers)) {
		cvers = "SQLite.JDBC0.JDBCConnection";
	    } else if (jvers == null || jvers.startsWith("1.0")) {
		throw new java.lang.Exception("unsupported java version");
	    } else if (jvers.startsWith("1.1")) {
		cvers = "SQLite.JDBC1.JDBCConnection";
	    } else if (jvers.startsWith("1.2") || jvers.startsWith("1.3")) {
		cvers = "SQLite.JDBC2.JDBCConnection";
	    } else if (jvers.startsWith("1.4")) {
		cvers = "SQLite.JDBC2x.JDBCConnection";
	    } else if (jvers.startsWith("1.5")) {
		cvers = "SQLite.JDBC2y.JDBCConnection";
		try {
		    Class.forName(cvers);
		} catch (java.lang.Exception e) {
		    cvers = "SQLite.JDBC2x.JDBCConnection";
		}
	    } else if (jvers.startsWith("1.6")) {
		cvers = "SQLite.JDBC2z.JDBCConnection";
		try {
		    Class.forName(cvers);
		} catch (java.lang.Exception e) {
		    cvers = "SQLite.JDBC2y.JDBCConnection";
		    try {
			Class.forName(cvers);
		    } catch (java.lang.Exception ee) {
			cvers = "SQLite.JDBC2x.JDBCConnection";
		    }
		}
	    } else {
		cvers = "SQLite.JDBC2z1.JDBCConnection";
		try {
		    Class.forName(cvers);
		} catch (java.lang.Exception e) {
		    cvers = "SQLite.JDBC2z.JDBCConnection";
		    try {
			Class.forName(cvers);
		    } catch (java.lang.Exception ee) {
			cvers = "SQLite.JDBC2y.JDBCConnection";
			try {
			    Class.forName(cvers);
			} catch (java.lang.Exception eee) {
			    cvers = "SQLite.JDBC2x.JDBCConnection";
			}
		    }
		}
	    }
 	    connClass = Class.forName(cvers);
	    makeConn = connClass.getConstructor(args);
	    try {
		String shcache =
		    java.lang.System.getProperty("SQLite.sharedcache");
		if (shcache != null &&
		    (shcache.startsWith("y") || shcache.startsWith("Y"))) {
		    sharedCache = SQLite.Database._enable_shared_cache(true);
		}
	    } catch (java.lang.Exception e) {
	    }
	    try {
		String tvfs = 
		    java.lang.System.getProperty("SQLite.vfs");
		if (tvfs != null) {
		    vfs = tvfs;
		}
	    } catch (java.lang.Exception e) {
	    }
	} catch (java.lang.Exception e) {
	    System.err.println(e);
	}
    }

    public JDBC() {
    }
	
    public boolean acceptsURL(String url) throws SQLException {
	return url.startsWith("sqlite:/") ||
	    url.startsWith("jdbc:sqlite:/");
    }

    public Connection connect(String url, Properties info)
	throws SQLException {
	if (!acceptsURL(url)) {
	    return null;
	}
	Object args[] = new Object[5];
	args[0] = url;
	if (info != null) {
	    args[1] = info.getProperty("encoding");
	    args[2] = info.getProperty("password");
	    args[3] = info.getProperty("daterepr");
	    args[4] = info.getProperty("vfs");
	}
	if (args[1] == null) {
	    args[1] = java.lang.System.getProperty("SQLite.encoding");
	}
	if (args[4] == null) {
	    args[4] = vfs;
	}
	try {
	    return (Connection) makeConn.newInstance(args);
	} catch (java.lang.reflect.InvocationTargetException ie) {
	    throw new SQLException(ie.getTargetException().toString());
	} catch (java.lang.Exception e) {
	    throw new SQLException(e.toString());
	}
    }

    public int getMajorVersion() {
	return MAJORVERSION;
    }

    public int getMinorVersion() {
	return Constants.drv_minor;
    }

 }