Java Reference
In-Depth Information
* obtained.
*/
private PreparedStatement obtainStatement() throws SQLException
{
PreparedStatement result = null;
try
{
this.mutex.acquire();
if (this.statementCache.size() == 0)
{
result =
this.manager.getConnection().prepareStatement(this.sql);
} else
{
result = this.statementCache.get(0);
this.statementCache.remove(0);
}
} catch (InterruptedException e)
{
return null;
} finally
{
this.mutex.release();
}
return result;
}
/**
* This method releases statements after the thread is
* done with them. These statements are not closed, but
* rather cached until another thread has need of them.
*
* @param stmt
* The statement that is to be released.
*/
private void releaseStatement(PreparedStatement stmt)
{
try
{
try
{
this.mutex.acquire();
} catch (InterruptedException e)
Search WWH ::




Custom Search