Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/main/java/com/marklogic/rowbot/QueryBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ public void run() {

try {
Properties props = new Properties();
JSONObject propsObj = connectionObj.getJSONObject("properties");
Iterator<String> itr = propsObj.keys();
while (itr.hasNext()) {
String key = itr.next();
props.put(key, propsObj.getString(key));
JSONObject propsObject = connectionObj.getJSONObject("properties");
Iterator<String> keys = propsObject.keys();
while (keys.hasNext()) {
String key = keys.next();
props.put(key, propsObject.getString(key));
}

this.connection = DriverManager.getConnection(connectionString, props);
Expand All @@ -92,6 +92,8 @@ public void run() {
double queryTime = 0;
long queryStart = System.nanoTime();
int rowNum = 0;
boolean success = true;
String successMsg = null;
try {
String query = this.queryObject.getString("query");
try (
Expand All @@ -114,6 +116,11 @@ public void run() {
Runnable insertThread = new InsertBot(rowMap, queryObject, rowNum, this.rowBot);
insertPool.execute(insertThread);
}
} catch (Exception e) {
System.out.println("Error with Query: " + query);
e.printStackTrace();
success = false;
successMsg = e.toString();
}

//signals pool to not accept more tasks.
Expand All @@ -125,10 +132,12 @@ public void run() {

long queryEnd = System.nanoTime();
queryTime = (queryEnd - queryStart) / QueryBot.NANO_TIME_DIV;
this.queryComplete(true, this.queryObject.getString("queryId"), this.queryObject.getString("query"), rowNum, queryTime, null);
} catch (Exception e) {
this.queryComplete(false, this.queryObject.getString("queryId"), this.queryObject.getString("query"), rowNum, queryTime, e.toString());
e.printStackTrace();
success = false;
successMsg = e.toString();
} finally {
this.queryComplete(success, this.queryObject.getString("queryId"), this.queryObject.getString("query"), rowNum, queryTime, successMsg);
// NOTE: connections are now closed in RowBot at the END.
session.close();
try {
Expand Down