Java Reference
In-Depth Information
The
getColumnSize
function can be used to determine the column's size. The
getColumnSize
function begins by calling the JDBC
getColumns
function. This
function will return a
ResultSet
that contains information about the specified table.
ResultSet rs = this.connection.getMetaData().getColumns(null,
null, table, null);
Next, the
getColumnSize
function loops through the results and finds the speci-
fied column.
while (rs.next()) {
String c = rs.getString("COLUMN_NAME");
int size = rs.getInt("COLUMN_SIZE");
if (c.equalsIgnoreCase(column)) {
return size;
}
}
return -1;
If the specified column is not found, then negative one is returned.
Summary
The
SQLWorkloadManager
allows the Heaton Research Spider to process large
workloads. To use the
SQLWorkloadManager
, you must have a database with the
SPIDER_WORKLOAD
and
SPIDER_HOST
tables.
The
SQLWorkloadManager
will automatically re-establish a JDBC connec-
tion if an error occurs. Using the
RepeatableStatement
class supports this. The
RepeatableStatement
class encapsulates a
PreparedStatement
. However,
unlike a
PreparedStatement
, the
RepeatableStatement
class will automat-
ically re-establish broken connections.
Not all web sites welcome spiders and bots. You should never create a spider or bot that
accesses a site in a way that is damaging to the site. You should always respect the wishes of
the web site owner. Creating well behaved bots is discussed in the next chapter.