FileDocCategorySizeDatePackage
TestHelper_Driver1.javaAPI DocAndroid 1.5 API3932Wed May 06 22:41:06 BST 2009org.apache.harmony.sql.tests.java.sql

TestHelper_Driver1

public class TestHelper_Driver1 extends Object implements Driver
A simple implementation of a class implementing a JDBC Driver, for use in the testing of the java.sql.DriverManager class

Fields Summary
int
majorVersion
int
minorVersion
String
baseURL
String[]
dataSources
static Driver
theDriver
static String
validuser
static String
validpassword
static String
userProperty
static String
passwordProperty
Constructors Summary
protected TestHelper_Driver1()

     
        theDriver = new TestHelper_Driver1();
        try {
            DriverManager.registerDriver(theDriver);
        } catch (SQLException e) {
            System.out.println("Failed to register driver!");
        }
    
        super();
    
Methods Summary
public booleanacceptsURL(java.lang.String url)

        // Check on the supplied String...
        if (url == null) {
            return false;
        }
        // Everything's fine if the quoted url starts with the base url for this
        // driver
        if (url.startsWith(baseURL)) {
            return true;
        }
        return false;
    
public java.sql.Connectionconnect(java.lang.String url, java.util.Properties info)


            
        // Does the URL have the right form?
        if (this.acceptsURL(url)) {
            // The datasource name is the remainder of the url after the ":"
            String datasource = url.substring(baseURL.length() + 1);
            for (String element : dataSources) {
                if (datasource.equals(element)) {
                    /*
                     * Check for user and password, except for datasource =
                     * data1 which is set up not to require a user/password
                     * combination
                     */
                    // It all checks out - so return a connection
                    Connection connection = new TestHelper_Connection1();
                    return connection;
                } // end if
            } // end for
        } // end if
        return null;
    
public intgetMajorVersion()

        return majorVersion;
    
public intgetMinorVersion()

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

        DriverPropertyInfo[] theInfos = { new DriverPropertyInfo(userProperty, "*"),
                new DriverPropertyInfo(passwordProperty, "*"), };
        return theInfos;
    
public booleanjdbcCompliant()

        // Basic version here returns false
        return false;