Revision 184
Added by Matt Jones almost 24 years ago
DBWriter.java | ||
---|---|---|
33 | 33 |
*/ |
34 | 34 |
public class DBWriter { |
35 | 35 |
|
36 |
static String defaultDB = "jdbc:oracle:thin:@penelope.nceas.ucsb.edu:1526:DEV8"; |
|
37 | 36 |
private Connection conn = null; |
38 | 37 |
|
39 | 38 |
/** |
40 | 39 |
* the main routine used to test the DBWriter utility. |
40 |
* <p> |
|
41 |
* Usage: java DBWriter <filename> |
|
41 | 42 |
* |
42 |
* Usage: java DBWriter <filename> <user> <password> [dbstring] |
|
43 |
* |
|
44 | 43 |
* @param filename the filename to be loaded into the database |
45 |
* @param user the username to use for the database connection |
|
46 |
* @param password the password to use for the database connection |
|
47 |
* @param dbstring the connection info to use for the database connection |
|
48 | 44 |
*/ |
49 | 45 |
static public void main(String[] args) { |
50 | 46 |
|
51 |
if (args.length < 3)
|
|
47 |
if (args.length < 1)
|
|
52 | 48 |
{ |
53 | 49 |
System.err.println("Wrong number of arguments!!!"); |
54 |
System.err.println("USAGE: java DBWriter " + |
|
55 |
"<filename> <user> <password> [dbstring]"); |
|
50 |
System.err.println("USAGE: java DBWriter <filename>"); |
|
56 | 51 |
return; |
57 | 52 |
} else { |
58 | 53 |
try { |
59 | 54 |
|
60 | 55 |
String filename = args[0]; |
61 |
String user = args[1]; |
|
62 |
String password = args[2]; |
|
63 |
String dbstring = null; |
|
64 | 56 |
|
65 |
if (args.length <= 3) { |
|
66 |
dbstring = defaultDB; |
|
67 |
} else { |
|
68 |
dbstring = args[3]; |
|
69 |
} |
|
70 |
|
|
71 | 57 |
// Open a connection to the database |
72 |
Connection dbconn = MetaCatUtil.openDBConnection( |
|
73 |
"oracle.jdbc.driver.OracleDriver", |
|
74 |
dbstring, user, password); |
|
58 |
MetaCatUtil util = new MetaCatUtil(); |
|
59 |
Connection dbconn = util.openDBConnection(); |
|
75 | 60 |
|
76 | 61 |
new DBWriter(filename, dbconn); |
77 | 62 |
System.out.println("Document processing finished for: " + filename); |
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