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

TestHelper_Driver4

public class TestHelper_Driver4 extends Object implements Driver
Basic JDBC driver implementation to help with tests

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

     
        Driver theDriver = new TestHelper_Driver4();
        try {
            DriverManager.registerDriver(theDriver);
        } catch (SQLException e) {
            System.out.println("Failed to register driver!");
        }
    
        super();
        baseURL = "jdbc:mikes4";
    
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
                     */
                    if (datasource.equals("data1")) {
                        // do nothing...
                    } else {
                        if (info == null) {
                            throw new SQLException("Properties bundle is null");
                        }
                        String user = (String) info.get(userProperty);
                        String password = (String) info.get(passwordProperty);
                        if (user == null || password == null) {
                            throw new SQLException("Userid and/or password not supplied");
                        }
                        if (!user.equals(validuser) || !password.equals(validpassword)) {
                            throw new SQLException("Userid and/or password not valid");
                        } // end if
                    } // end if
                    // 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;