FileDocCategorySizeDatePackage
DatabaseCreator.javaAPI DocAndroid 1.5 API18028Wed May 06 22:41:06 BST 2009tests.support

DatabaseCreator

public class DatabaseCreator extends Object

Fields Summary
public static final int
defaultInt
public static final String
defaultString
public static final String
defaultCharacter
public static final double
defaultDouble
public static final String
TEST_TABLE1
public static final String
TEST_TABLE2
public static final String
TEST_TABLE3
public static final String
TEST_TABLE4
public static final String
SALESPEOPLE_TABLE
public static final String
CUSTOMERS_TABLE
public static final String
ORDERS_TABLE
public static final String
PARENT_TABLE
public static final String
FKSTRICT_TABLE
public static final String
FKCASCADE_TABLE
public static final String
TEST_TABLE5
public static final String
SIMPLE_TABLE1
public static final String
SIMPLE_TABLE2
public static final String
SIMPLE_TABLE3
public static final String
CREATE_TABLE1
public static final String
CREATE_TABLE2
public static final String
CREATE_TABLE3
public static final String
CREATE_TABLE4
public static final String
CREATE_TABLE5
public static final String
CREATE_TABLE_SALESPEOPLE
public static final String
CREATE_TABLE_CUSTOMERS
public static final String
CREATE_TABLE_ORDERS
public static final String
CREATE_TABLE_PARENT
public static final String
CREATE_TABLE_FKSTRICT
public static final String
CREATE_TABLE_FKCASCADE
public static final String
CREATE_TABLE_SIMPLE1
public static final String
CREATE_TABLE_SIMPLE2
public static final String
CREATE_TABLE_SIMPLE3
public static final String
DROP_TABLE1
public static final String
DROP_TABLE2
public static final String
DROP_TABLE3
public static final String
DROP_TABLE4
public static final String
DROP_TABLE5
public static final String
DROP_TABLE_CUSTOMERS
public static final String
DROP_TABLE_ORDERS
public static final String
DROP_TABLE_SALESPEOPLE
public static final String
DROP_TABLE_PARENT
public static final String
DROP_TABLE_FKSTRICT
public static final String
DROP_TABLE_FKCASCADE
public static final String
DROP_TABLE_SIMPLE1
public static final String
DROP_TABLE_SIMPLE2
public static final String
DROP_TABLE_SIMPLE3
public static final String
INSERT_SALESPEOPLE1
public static final String
INSERT_SALESPEOPLE2
public static final String
INSERT_SALESPEOPLE3
public static final String
INSERT_SALESPEOPLE4
public static final String
INSERT_SALESPEOPLE5
public static final String
INSERT_SALESPEOPLE6
public static final String
INSERT_CUSTOMERS1
public static final String
INSERT_CUSTOMERS2
public static final String
INSERT_CUSTOMERS3
public static final String
INSERT_CUSTOMERS4
public static final String
INSERT_CUSTOMERS5
public static final String
INSERT_CUSTOMERS6
public static final String
INSERT_CUSTOMERS7
public static final String
INSERT_ORDERS1
public static final String
INSERT_ORDERS2
public static final String
INSERT_ORDERS3
public static final String
INSERT_ORDERS4
public static final String
INSERT_ORDERS5
public static final String
INSERT_ORDERS6
public static final String
INSERT_ORDERS7
public static final String
INSERT_ORDERS8
public static final String
INSERT_ORDERS9
public static final String
INSERT_ORDERS10
Constructors Summary
Methods Summary
public static voidfillCustomersTable(java.sql.Connection conn)

        Statement statement = conn.createStatement();

        statement.execute(DatabaseCreator.INSERT_CUSTOMERS1);
        statement.execute(DatabaseCreator.INSERT_CUSTOMERS2);
        statement.execute(DatabaseCreator.INSERT_CUSTOMERS3);
        statement.execute(DatabaseCreator.INSERT_CUSTOMERS4);
        statement.execute(DatabaseCreator.INSERT_CUSTOMERS5);
        statement.execute(DatabaseCreator.INSERT_CUSTOMERS6);
        statement.execute(DatabaseCreator.INSERT_CUSTOMERS7);
    
public static voidfillFKCascadeTable(java.sql.Connection conn)

        Statement statement = conn.createStatement();
        statement.execute("INSERT INTO " + FKCASCADE_TABLE
                + " VALUES(1, 1, '1')");
        statement.execute("INSERT INTO " + FKCASCADE_TABLE
                + " VALUES(2, 2, '2')");
        statement.execute("INSERT INTO " + FKCASCADE_TABLE
                + " VALUES(3, 1, '3')");
    
public static voidfillFKStrictTable(java.sql.Connection conn)

        Statement statement = conn.createStatement();
        statement.execute("INSERT INTO " + FKSTRICT_TABLE
                + " VALUES(1, 1, '1')");
        statement.execute("INSERT INTO " + FKSTRICT_TABLE
                + " VALUES(2, 2, '2')");
        statement.execute("INSERT INTO " + FKSTRICT_TABLE
                + " VALUES(3, 1, '3')");
    
public static voidfillOrdersTable(java.sql.Connection conn)

        Statement statement = conn.createStatement();

        statement.execute(DatabaseCreator.INSERT_ORDERS1);
        statement.execute(DatabaseCreator.INSERT_ORDERS2);
        statement.execute(DatabaseCreator.INSERT_ORDERS3);
        statement.execute(DatabaseCreator.INSERT_ORDERS4);
        statement.execute(DatabaseCreator.INSERT_ORDERS5);
        statement.execute(DatabaseCreator.INSERT_ORDERS6);
        statement.execute(DatabaseCreator.INSERT_ORDERS7);
        statement.execute(DatabaseCreator.INSERT_ORDERS8);
        statement.execute(DatabaseCreator.INSERT_ORDERS9);
        statement.execute(DatabaseCreator.INSERT_ORDERS10);
    
public static voidfillParentTable(java.sql.Connection conn)


           
        Statement statement = conn.createStatement();
        statement
                .execute("INSERT INTO " + PARENT_TABLE + " VALUES(1, 'test1')");
        statement.execute("INSERT INTO " + PARENT_TABLE + " VALUES(2,'test2')");
        statement
                .execute("INSERT INTO " + PARENT_TABLE + " VALUES(3, 'test3')");
    
public static voidfillSalesPeopleTable(java.sql.Connection conn)

        Statement statement = conn.createStatement();

        statement.execute(DatabaseCreator.INSERT_SALESPEOPLE1);
        statement.execute(DatabaseCreator.INSERT_SALESPEOPLE2);
        statement.execute(DatabaseCreator.INSERT_SALESPEOPLE3);
        statement.execute(DatabaseCreator.INSERT_SALESPEOPLE4);
        statement.execute(DatabaseCreator.INSERT_SALESPEOPLE5);
        statement.execute(DatabaseCreator.INSERT_SALESPEOPLE6);
    
public static voidfillSimpleTable1(java.sql.Connection conn)

        Statement statement = conn.createStatement();
        statement
                .execute("INSERT INTO " + SIMPLE_TABLE1 + " VALUES(1, 10, 20)");
        statement.execute("INSERT INTO " + SIMPLE_TABLE1 + " VALUES(2, 5, 7)");
    
public static voidfillSimpleTable3(java.sql.Connection conn)

        Statement statement = conn.createStatement();
        statement.execute("INSERT INTO " + SIMPLE_TABLE3 + " VALUES(1, 8)");
        statement.execute("INSERT INTO " + SIMPLE_TABLE3 + " VALUES(2, 6)");
        statement.execute("INSERT INTO " + SIMPLE_TABLE3 + " VALUES(3, 4)");
    
public static voidfillTestTable1(java.sql.Connection conn, int numberOfRecords)

        Statement statement = conn.createStatement();
        for (int id = 0; id < numberOfRecords; id++) {
            String value = DatabaseCreator.defaultString + id;
            String insertQuery = "INSERT INTO " + DatabaseCreator.TEST_TABLE1
                    + " (id, field1, field2, field3) VALUES(" + id + ", '"
                    + value + "', " + id + ", " + id + ")";
            statement.execute(insertQuery);
        }
    
public static voidfillTestTable2(java.sql.Connection conn, int startID, int endID, long time)

        Statement statement = conn.createStatement();
        for (int id = startID; id <= endID; id++) {
            double value = id + DatabaseCreator.defaultDouble;
            String insertQuery = "INSERT INTO " + DatabaseCreator.TEST_TABLE2
                    + " (finteger, ftext, fcharacter, fdecimal, fnumeric,"
                    + " fsmallint, ffloat, freal, fdouble, fdate, ftime)"
                    + " VALUES (" + id + ", '" + DatabaseCreator.defaultString
                    + id + "'," + " '" + DatabaseCreator.defaultCharacter + id
                    + "', " + value + ", " + value + "," + value + ", " + value
                    + ", " + value + "," + value + ", '"
                    + new Date(time).toString() + "'," + " '"
                    + new Time(time).toString() + "')";
            statement.execute(insertQuery);
        }
    
public static voidfillTestTable2(java.sql.Connection conn, int numberOfRecords)

        Statement statement = conn.createStatement();
        for (int id = 0; id < numberOfRecords; id++) {
            double value = id + DatabaseCreator.defaultDouble;
            String insertQuery = "INSERT INTO " + DatabaseCreator.TEST_TABLE2
                    + " (finteger, ftext, fcharacter, fdecimal, fnumeric,"
                    + " fsmallint, ffloat, freal, fdouble)" + " VALUES (" + id
                    + ", '" + DatabaseCreator.defaultString + id + "'," + " '"
                    + DatabaseCreator.defaultCharacter + id + "', " + value
                    + ", " + value + "," + value + ", " + value + ", " + value
                    + "," + value + ")";
            statement.execute(insertQuery);
        }
    
public static voidfillTestTable4(java.sql.Connection conn, int numberOfRecords)

        Statement statement = conn.createStatement();
        for (int id = 0; id < numberOfRecords; id++) {
            String insertQuery = "INSERT INTO " + DatabaseCreator.TEST_TABLE4
                    + " (fk, field1) VALUES(" + id + ", \""
                    + DatabaseCreator.defaultString + id + "\")";
            statement.execute(insertQuery);
        }
    
public static voidfillTestTable5(java.sql.Connection conn)

        Statement statement = conn.createStatement();
        statement.execute("INSERT INTO " + TEST_TABLE5 + " VALUES(1, '0')");
        statement.execute("INSERT INTO " + TEST_TABLE5 + " VALUES(2, '3')");
        statement.execute("INSERT INTO " + TEST_TABLE5 + " VALUES(3, '4')");