01: import java.sql.Connection;
02: import java.sql.ResultSet;
03: import java.sql.Statement;
04: 
05: /**
06:    Tests a database installation by creating and querying
07:    a sample table. Call this program as
08:    java -classpath driver_class_path;. TestDB database.properties
09: */
10: public class TestDB 
11: {
12:    public static void main(String[] args) throws Exception
13:    {   
14:       if (args.length == 0)
15:       {   
16:          System.out.println(
17:             "Usage: TestDB propertiesFile");
18:          System.exit(0);
19:       }
20:       else 
21:          SimpleDataSource.init(args[0]);
22:       
23:       Connection conn = SimpleDataSource.getConnection();
24: 
25:       Statement stat = conn.createStatement();
26: 
27:       stat.execute("CREATE TABLE Test (Name CHAR(20))");
28:       stat.execute("INSERT INTO Test VALUES ('Romeo')");
29: 
30:       ResultSet result = stat.executeQuery("SELECT * FROM Test");
31:       result.next();
32:       System.out.println(result.getString("Name"));
33:       result.close();
34: 
35:       stat.execute("DROP TABLE Test");
36:       
37:       stat.close();
38:       conn.close();
39:    }
40: }