Revision 18
Added by Matt Jones over 24 years ago
DBSAXElement.java | ||
---|---|---|
20 | 20 |
private long element_id; |
21 | 21 |
private String tagname; |
22 | 22 |
private StringBuffer content; |
23 |
private boolean isEmpty; |
|
24 | 23 |
private long parent_id; |
25 | 24 |
private Hashtable attributes; |
26 | 25 |
private Connection conn; |
27 | 26 |
|
28 |
public DBSAXElement (Connection conn, long element_id, String tagname,
|
|
29 |
boolean isEmpty, long parent_id) {
|
|
27 |
public DBSAXElement (Connection conn, String tagname, |
|
28 |
long parent_id) { |
|
30 | 29 |
this.conn = conn; |
31 | 30 |
this.element_id = assignElementID(); |
32 | 31 |
|
33 | 32 |
this.tagname = tagname; |
34 |
this.isEmpty = isEmpty; |
|
35 | 33 |
this.parent_id = parent_id; |
36 | 34 |
content = new StringBuffer(); |
37 | 35 |
attributes = new Hashtable(); |
38 | 36 |
writeElementToDB(); |
39 |
|
|
40 |
System.out.println("******ELEMENT_ID: " + this.element_id); |
|
41 | 37 |
}; |
42 | 38 |
|
43 | 39 |
private long assignElementID() { |
... | ... | |
111 | 107 |
return value.toString (); |
112 | 108 |
} |
113 | 109 |
|
110 |
/** Get the id of this element */ |
|
111 |
public long getElementID() { return element_id; } |
|
112 |
|
|
114 | 113 |
/** Get the name of this element */ |
115 | 114 |
public String getTagName() { return tagname; } |
116 | 115 |
|
... | ... | |
157 | 156 |
public String getContent() { |
158 | 157 |
return this.content.toString(); |
159 | 158 |
} |
159 |
|
|
160 |
/** Write the element content to the db connection */ |
|
161 |
public void writeContentToDB() { |
|
162 |
try { |
|
163 |
PreparedStatement pstmt = conn.prepareStatement( |
|
164 |
"UPDATE xml_elements SET nodedata = ? WHERE nodeid = ?"); |
|
165 |
|
|
166 |
// Bind the values to the query |
|
167 |
pstmt.setString(1, getContent());// The first ? is for NODEDATA |
|
168 |
pstmt.setLong(2, element_id); // The second ? is for NODEID |
|
169 |
|
|
170 |
// Do the update |
|
171 |
pstmt.execute(); |
|
172 |
pstmt.close(); |
|
173 |
|
|
174 |
} catch (SQLException e) { |
|
175 |
System.out.println(e.getMessage()); |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
160 | 179 |
} |
Also available in: Unified diff
Partially functional SAS DB loader.