Java Reference
In-Depth Information
{
return;
}
this.statementCache.add(stmt);
} finally
{
this.mutex.release();
}
}
}
As you can see from the above listing, the RepeatableStatement class defines
several instance variables. These instance variables are defined in Table 15.1.
Table 15.1: Instance Variables of the RepeatableStatement Class
Instance Variable Purpose
manager
The SQLWorkloadManager that created this object. This is used to
reopen the database connection, when needed.
sql
The SQL for this statement. This is used to recreate the Prepared-
Statement when needed.
mutex
A mutex to make sure that only one thread at a time is in the
process of getting a PreparedStatement assigned. More than one
thread at a time can have a PreparedStatement; however, only one
can be in the obtainStatement function at a time.
statementCache
The PreparedStatements that are assigned to each thread.
There are also several methods and functions that make up the
RepeatableStatement class. These methods and functions will be discussed in the
next few sections.
Executing SQL Commands
The execute method is used to execute SQL commands that do not return a
ResultSet . The execute method makes use of the variable argument count feature
of JDK 1.5. This allows a number of parameters to be included with the SQL command. Pa-
rameters were discussed earlier in this chapter.
public void execute(Object... parameters) throws WorkloadException
{
PreparedStatement statement = null;
Next, a statement is obtained by calling the obtainStatement function. The
obtainStatement function will be covered later in this chapter.
Search WWH ::




Custom Search