Project

General

Profile

« Previous | Next » 

Revision 184

cleaned up code for getting options from the properties file, made the database connection inthe MetaCatUtil class use the properties file for the conneciton info

View differences:

DBSimpleQuery.java
28 28
 */
29 29
public class DBSimpleQuery {
30 30

  
31
  static  String 	defaultDB = "jdbc:oracle:thin:@localhost:1521:test";
32 31
  private Connection	conn = null;
33 32

  
34 33
  /**
35 34
   * the main routine used to test the DBSimpleQuery utility.
35
   * <p>
36
   * Usage: java DBSimpleQuery <query>
36 37
   *
37
   * Usage: java DBSimpleQuery <query> <user> <password> [dbstring]
38
   *
39 38
   * @param query the text to search for in the element and attribute content
40
   * @param user the username to use for the database connection
41
   * @param password the password to use for the database connection
42
   * @param dbstring the connection info to use for the database connection
43 39
   */
44 40
  static public void main(String[] args) {
45 41
     
46
     if (args.length < 4)
42
     if (args.length < 2)
47 43
     {
48 44
        System.err.println("Wrong number of arguments!!!");
49
        System.err.println("USAGE: java DBSimpleQuery " +
50
                           "<query> <doctype> <user> <password> [dbstring]");
45
        System.err.println("USAGE: java DBSimpleQuery <query> <doctype>");
51 46
        return;
52 47
     } else {
53 48
        try {
54 49
                    
55 50
          String query    = args[0];
56 51
          String doctype  = args[1];
57
          String user     = args[2];
58
          String password = args[3];
59
          String dbstring = null;
60 52

  
61
          if (args.length <= 4) {
62
            dbstring = defaultDB;
63
          } else {
64
            dbstring = args[4];
65
          }
53
          // Open a connection to the database
54
          MetaCatUtil   util = new MetaCatUtil();
55
          Connection dbconn = util.openDBConnection();
66 56

  
67
          // Open a connection to the database
68
          Connection dbconn = MetaCatUtil.openDBConnection( 
69
                              "oracle.jdbc.driver.OracleDriver",
70
                              dbstring, user, password);
71 57
          // Execute the simple query
72 58
          DBSimpleQuery rd = new DBSimpleQuery(dbconn);
73 59
          Hashtable nodelist = null;

Also available in: Unified diff