FileDocCategorySizeDatePackage
JDBCDriver.javaAPI DocAndroid 1.5 API3216Wed May 06 22:41:06 BST 2009SQLite

JDBCDriver

public class JDBCDriver extends Object implements Driver

Fields Summary
public static final int
MAJORVERSION
public static final int
MINORVERSION
private static Constructor
makeConn
protected Connection
conn
Constructors Summary
public JDBCDriver()


     
    try {
        Class connClass = null;
        Class args[] = new Class[2];
        args[0] = Class.forName("java.lang.String");
        args[1] = args[0];
        String jvers = java.lang.System.getProperty("java.version");
        String cvers;
        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 {
        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";
            }
        }
        }
        connClass = Class.forName(cvers);
        makeConn = connClass.getConstructor(args);
        java.sql.DriverManager.registerDriver(new JDBCDriver());
    } catch (java.lang.Exception e) {
        System.err.println(e);
    }
    
    
Methods Summary
public booleanacceptsURL(java.lang.String url)

    return url.startsWith("sqlite:/") ||
        url.startsWith("jdbc:sqlite:/");
    
public java.sql.Connectionconnect(java.lang.String url, java.util.Properties info)

    if (!acceptsURL(url)) {
        return null;
    }
    Object args[] = new Object[2];
    args[0] = url;
    if (info != null) {
        args[1] = info.getProperty("encoding");
    }
    if (args[1] == null) {
        args[1] = java.lang.System.getProperty("SQLite.encoding");
    }
    try {
        conn = (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());
    }
    return conn;
    
public intgetMajorVersion()

    return MAJORVERSION;
    
public intgetMinorVersion()

    return MINORVERSION;
    
public java.sql.DriverPropertyInfo[]getPropertyInfo(java.lang.String url, java.util.Properties info)

    DriverPropertyInfo p[] = new DriverPropertyInfo[1];
    DriverPropertyInfo pp = new DriverPropertyInfo("encoding", "");
    p[0] = pp;
    return p;
    
public booleanjdbcCompliant()

    return false;