111 |
111 |
result.append("<?xml version=\"1.0\"?>\n");
|
112 |
112 |
result.append("<resultset>\n");
|
113 |
113 |
// following line removed by Dan Higgins to avoid insertion of query XML inside returned XML doc
|
114 |
|
// result.append(" <query>" + xmlfile + "</query>\n");
|
115 |
|
Enumeration doclist = nodelist.keys();
|
116 |
|
while (doclist.hasMoreElements()) {
|
117 |
|
docid = (String)doclist.nextElement();
|
118 |
|
document = (String)nodelist.get(docid);
|
119 |
|
result.append(" <document>\n " + document +
|
120 |
|
"\n </document>\n");
|
|
114 |
// result.append(" <query>" + xmlfile + "</query>\n");
|
|
115 |
if(!showRuntime)
|
|
116 |
{
|
|
117 |
Enumeration doclist = nodelist.keys();
|
|
118 |
while (doclist.hasMoreElements()) {
|
|
119 |
docid = (String)doclist.nextElement();
|
|
120 |
document = (String)nodelist.get(docid);
|
|
121 |
result.append(" <document>\n " + document +
|
|
122 |
"\n </document>\n");
|
|
123 |
}
|
|
124 |
|
|
125 |
result.append("</resultset>\n");
|
121 |
126 |
}
|
122 |
|
result.append("</resultset>\n");
|
123 |
|
|
124 |
127 |
// Time the request if asked for
|
125 |
128 |
double stopTime = System.currentTimeMillis();
|
126 |
129 |
double dbOpenTime = (connTime - startTime)/1000;
|
127 |
130 |
double readTime = (stopTime - connTime)/1000;
|
128 |
131 |
double executionTime = (stopTime - startTime)/1000;
|
129 |
132 |
if (showRuntime) {
|
130 |
|
System.out.println("\n\nTotal Execution time was: " +
|
131 |
|
executionTime + " seconds.");
|
132 |
|
System.out.println("Time to open DB connection was: " + dbOpenTime +
|
133 |
|
" seconds.");
|
134 |
|
System.out.println("Time to read was: " + readTime +
|
135 |
|
" seconds.");
|
|
133 |
System.out.print(" " + executionTime);
|
|
134 |
System.out.print(" " + dbOpenTime);
|
|
135 |
System.out.print(" " + readTime);
|
|
136 |
System.out.print(" " + nodelist.size());
|
|
137 |
System.out.println();
|
136 |
138 |
}
|
137 |
139 |
//System.out.println(result);
|
138 |
140 |
//write into a file "result.txt"
|
139 |
|
File f = new File("./result.txt");
|
140 |
|
FileWriter fw = new FileWriter(f);
|
141 |
|
BufferedWriter out = new BufferedWriter(fw);
|
142 |
|
out.write(result.toString());
|
143 |
|
out.flush();
|
144 |
|
out.close();
|
145 |
|
fw.close();
|
146 |
|
|
147 |
|
} catch (Exception e) {
|
|
141 |
if(!showRuntime)
|
|
142 |
{
|
|
143 |
File f = new File("./result.txt");
|
|
144 |
FileWriter fw = new FileWriter(f);
|
|
145 |
BufferedWriter out = new BufferedWriter(fw);
|
|
146 |
out.write(result.toString());
|
|
147 |
out.flush();
|
|
148 |
out.close();
|
|
149 |
fw.close();
|
|
150 |
}
|
|
151 |
|
|
152 |
}
|
|
153 |
catch (Exception e) {
|
148 |
154 |
System.err.println("Error in DBQuery.main");
|
149 |
155 |
System.err.println(e.getMessage());
|
150 |
156 |
e.printStackTrace(System.err);
|
... | ... | |
220 |
226 |
}
|
221 |
227 |
|
222 |
228 |
try {
|
223 |
|
dbconn = util.openDBConnection();
|
|
229 |
if(conn == null)
|
|
230 |
{
|
|
231 |
dbconn = util.openDBConnection();
|
|
232 |
}
|
|
233 |
else
|
|
234 |
{
|
|
235 |
dbconn = conn;
|
|
236 |
}
|
224 |
237 |
// Get the XML query and covert it into a SQL statment
|
225 |
238 |
QuerySpecification qspec = new QuerySpecification(xmlquery,
|
226 |
239 |
parserName,
|
added print info and timing info