FileDocCategorySizeDatePackage
Support_SQL.javaAPI DocAndroid 1.5 API3734Wed May 06 22:41:06 BST 2009tests.support

Support_SQL

public class Support_SQL extends Object

Fields Summary
public static String
sqlDriver
public static String
sqlLogin
public static String
sqlCatalog
public static String
sqlHost
public static String
sqlUrl
public static String
sqlPassword
public static String
sqlUser
public static int
sqlMaxConnections
public static int
sqlMaxTasks
private static File
dbFile
Constructors Summary
Methods Summary
public static java.sql.ConnectiongetConnection()

        return DriverManager.getConnection(Support_SQL.sqlUrl,
                Support_SQL.sqlLogin, Support_SQL.sqlPassword);
    
public static java.sql.ConnectiongetConnection(java.lang.String url, java.lang.String login, java.lang.String password)


        return DriverManager.getConnection(url, login, password);
    
public static java.lang.StringgetFilename()

        return dbFile.getPath();
    
public static booleanisEqual(byte[] b1, int off1, byte[] b2, int off2, int len)

        for (int i = 0; i < len; ++i)
            if (b1[i + off1] != b2[i + off2])
                return false;
        return true;
    
public static voidloadDriver()


        
        try {
            loadProperties(Class.forName("tests.support.Support_SQL")
                    .getResourceAsStream("/connection.properties"));

            String tmp = System.getProperty("java.io.tmpdir");
            File tmpDir = new File(tmp);
            if (tmpDir.isDirectory()) {
                dbFile = File.createTempFile("sqliteTest", ".db", tmpDir);
                dbFile.deleteOnExit();
            } else {
                System.err.println("java.io.tmpdir does not exist");
            }
            Class.forName("SQLite.JDBCDriver").newInstance();

            // overwrite sqlUrl to point to valid directory
            sqlUrl = "jdbc:sqlite:/" + dbFile.getPath();

            Class.forName(sqlDriver).newInstance();
        } catch (Exception ex) {
            System.err.println("Unexpected exception " + ex.toString());
        }
    
private static voidloadProperties(java.io.InputStream fileName)

        Properties properties = new Properties();
        properties.load(fileName);
        sqlDriver = properties.getProperty("sqlDriver");
        sqlLogin = properties.getProperty("sqlLogin");
        sqlCatalog = properties.getProperty("sqlCatalog");
        sqlHost = properties.getProperty("sqlHost");
        sqlUrl = properties.getProperty("sqlUrlPrefix") + sqlHost + "/"
                + sqlCatalog;
        sqlPassword = properties.getProperty("sqlPassword");
        sqlUser = properties.getProperty("sqlUser");
        sqlMaxConnections = Integer.parseInt(properties
                .getProperty("sqlMaxConnections"));
        sqlMaxTasks = Integer.parseInt(properties.getProperty("sqlMaxTasks"));