Revision 184
Added by Matt Jones almost 24 years ago
DBReader.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
public class DBReader { |
25 | 25 |
|
26 |
static String defaultDB = "jdbc:oracle:thin:@localhost:1521:test"; |
|
27 | 26 |
private Connection conn = null; |
28 | 27 |
|
29 | 28 |
/** |
30 | 29 |
* main routine used for testing. |
30 |
* <p> |
|
31 |
* Usage: java DBReader <docid> |
|
31 | 32 |
* |
32 |
* Usage: java DBReader <nodeid> <user> <password> [dbstring] |
|
33 |
* |
|
34 | 33 |
* @param nodeid the id number of the root of the subtree to display |
35 |
* @param user the username to use for the database connection |
|
36 |
* @param password the password to use for the database connection |
|
37 |
* @param dbstring the connection info to use for the database connection |
|
38 | 34 |
*/ |
39 | 35 |
static public void main(String[] args) { |
40 | 36 |
|
41 |
if (args.length < 3)
|
|
37 |
if (args.length < 1)
|
|
42 | 38 |
{ |
43 | 39 |
System.err.println("Wrong number of arguments!!!"); |
44 |
System.err.println("USAGE: java DBReader " + |
|
45 |
"<nodeid> <user> <password> [dbstring]"); |
|
40 |
System.err.println("USAGE: java DBReader <docid>"); |
|
46 | 41 |
return; |
47 | 42 |
} else { |
48 | 43 |
try { |
49 | 44 |
|
50 |
String nodeidstr = args[0]; |
|
51 |
String nodeid = nodeidstr; |
|
52 |
//long nodeid = (new Long(nodeidstr).longValue()); |
|
53 |
String user = args[1]; |
|
54 |
String password = args[2]; |
|
55 |
String dbstring = null; |
|
45 |
String docid = args[0]; |
|
56 | 46 |
|
57 |
if (args.length <= 3) { |
|
58 |
dbstring = defaultDB; |
|
59 |
} else { |
|
60 |
dbstring = args[3]; |
|
61 |
} |
|
62 |
|
|
63 | 47 |
// Open a connection to the database |
64 |
Connection dbconn = MetaCatUtil.openDBConnection( |
|
65 |
"oracle.jdbc.driver.OracleDriver", |
|
66 |
dbstring, user, password); |
|
48 |
MetaCatUtil util = new MetaCatUtil(); |
|
49 |
Connection dbconn = util.openDBConnection(); |
|
67 | 50 |
|
68 | 51 |
DBReader rd = new DBReader( dbconn ); |
69 |
String xml = rd.readXMLDocument(nodeid);
|
|
52 |
String xml = rd.readXMLDocument(docid);
|
|
70 | 53 |
System.out.println(xml); |
71 | 54 |
|
72 | 55 |
} catch (Exception e) { |
Also available in: Unified diff
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