62,614
社区成员
发帖
与我相关
我的任务
分享
public synchronized void close()
throws SQLException
{
realClose(true, true);
}
protected void realClose(boolean calledExplicitly, boolean closeOpenResults)
throws SQLException
{
if(useUsageAdvisor && numberOfExecutions <= 1)
{
String message = Messages.getString("PreparedStatement.43");
eventSink.consumeEvent(new ProfilerEvent((byte)0, "", currentCatalog, connectionId, getId(), -1, System.currentTimeMillis(), 0L, Constants.MILLIS_I18N, null, pointOfOrigin, message));
}
super.realClose(calledExplicitly, closeOpenResults);
//上面一句调用了父类的realClose()方法, 父类StatementImpl的这个方法代码在下面..
//下面这些地方做了很多成员的释放...
dbmd = null;
originalSql = null;
staticSqlStrings = (byte[][])null;
parameterValues = (byte[][])null;
parameterStreams = null;
isStream = null;
streamLengths = null;
isNull = null;
streamConvertBuf = null;
parameterTypes = null;
}
protected void realClose(boolean calledExplicitly, boolean closeOpenResults)
throws SQLException
{
if(isClosed)
return;
if(useUsageAdvisor && !calledExplicitly)
{
String message = Messages.getString("Statement.63") + Messages.getString("Statement.64");
eventSink.consumeEvent(new ProfilerEvent((byte)0, "", currentCatalog, connectionId, getId(), -1, System.currentTimeMillis(), 0L, Constants.MILLIS_I18N, null, pointOfOrigin, message));
}
if(closeOpenResults)
closeOpenResults = !holdResultsOpenOverClose;
if(closeOpenResults)
{
if(results != null)
try
{
results.close();
}
catch(Exception ex) { }
closeAllOpenResults();
}
if(connection != null)
{
if(maxRowsChanged)
connection.unsetMaxRows(this);
if(!connection.getDontTrackOpenResources())
connection.unregisterStatement(this);
}
//同样,下面有很多的释放语句
isClosed = true;
results = null;
connection = null;
warningChain = null;
openResults = null;
batchedGeneratedKeys = null;
localInfileInputStream = null;
pingTarget = null;
}