Revision 31
Added by Matt Jones over 24 years ago
DBSAXWriter.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import oracle.xml.parser.v2.SAXParser; |
27 | 27 |
|
28 |
/** |
|
29 |
* A Class that reads in an XML text document and |
|
30 |
* write its contents to a database connection using SAX |
|
31 |
*/ |
|
28 | 32 |
public class DBSAXWriter { |
29 | 33 |
|
30 | 34 |
static String defaultDB = "jdbc:oracle:thin:@localhost:1521:test"; |
31 | 35 |
private Connection conn = null; |
32 | 36 |
|
37 |
/** |
|
38 |
* the main routine used to test the DBSAXWriter utility. |
|
39 |
* |
|
40 |
* Usage: java DBSAXWriter <filename> <user> <password> [dbstring] |
|
41 |
* |
|
42 |
* @param filename the filename to be loaded into the database |
|
43 |
* @param user the username to use for the database connection |
|
44 |
* @param password the password to use for the database connection |
|
45 |
* @param dbstring the connection info to use for the database connection |
|
46 |
*/ |
|
33 | 47 |
static public void main(String[] args) { |
34 | 48 |
|
35 | 49 |
if (args.length < 3) |
... | ... | |
63 | 77 |
} |
64 | 78 |
} |
65 | 79 |
|
80 |
/** |
|
81 |
* construct a new instance of the class to write an XML file to the database |
|
82 |
* |
|
83 |
* @param filename the filename to be loaded into the database |
|
84 |
* @param user the username to use for the database connection |
|
85 |
* @param password the password to use for the database connection |
|
86 |
* @param dbstring the connection info to use for the database connection |
|
87 |
*/ |
|
66 | 88 |
public DBSAXWriter( String filename, String user, |
67 | 89 |
String password, String dbstring) |
68 | 90 |
throws IOException, |
... | ... | |
121 | 143 |
|
122 | 144 |
} |
123 | 145 |
|
146 |
/** Utility method to establish the JDBC connection */ |
|
124 | 147 |
private Connection openDBConnection(String dbDriver, String connection, |
125 | 148 |
String user, String password) |
126 | 149 |
throws SQLException, ClassNotFoundException { |
... | ... | |
132 | 155 |
return conn; |
133 | 156 |
} |
134 | 157 |
|
158 |
/** Utility method to convert a file handle into a URL */ |
|
135 | 159 |
static public URL fileToURL(File file) |
136 | 160 |
{ |
137 | 161 |
String path = file.getAbsolutePath(); |
Also available in: Unified diff
documentation additions