Java Reference
In-Depth Information
Next, the results will be examined. The SQL was constructed so that each of the status
types will be returned in a separate row, along with a count. As we loop over everything that
was returned, we examine the status of each row and assign it to the correct total vari-
able.
while (rs.next()) {
String status = rs.getString(1);
int count = rs.getInt(2);
if (status.equalsIgnoreCase("W")) {
this.waiting = count;
} else if (status.equalsIgnoreCase("P")) {
this.processing = count;
} else if (status.equals("E")) {
this.error = count;
} else if (status.equals("D")) {
this.done = count;
}
}
rs.close();
Once this completes, we can close the result set.
Next, we execute the stmtDepth query. This simple SQL query obtains the maxi-
mum depth that was recorded in the spider_workload table.
this.depth = 0;
rs = this.stmtDepth.executeQuery();
if (rs.next()) {
this.depth = rs.getInt(1);
}
rs.close();
Once the depth has been obtained, the result set can be closed.
} catch (SQLException e) {
e.printStackTrace();
}
If any errors occur, a stack trace is displayed.
Displaying the Statistics
Now that we have obtained the statistics from the database, we can display them. First, a
string is created for each of the statistics that will be displayed.
final String stat1 = "Total URL\'s Encountered:";
final String stat2 = "Completed URL\'s:";
final String stat3 = "Waiting URL\'s:";
final String stat4 = "URL\'s Currently Processing:";
Search WWH ::




Custom Search