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: java -classpath driver_class_path;."
18:                + " TestDB database.properties");
19:          return;
20:       }
21:       else 
22:          SimpleDataSource.init(args[0]);
23:       
24:       Connection conn = SimpleDataSource.getConnection();
25:       try
26:       {
27:          Statement stat = conn.createStatement();
28: 
29:          stat.execute("CREATE TABLE Test (Name CHAR(20))");
30:          stat.execute("INSERT INTO Test VALUES ('Romeo')");
31: 
32:          ResultSet result = stat.executeQuery("SELECT * FROM Test");
33:          result.next();
34:          System.out.println(result.getString("Name"));
35: 
36:          stat.execute("DROP TABLE Test");
37:       }
38:       finally
39:       {
40:          conn.close();
41:       }
42:    }
43: }