use of com.mysql.cj.exceptions.CJException in project aws-mysql-jdbc by awslabs.
the class ResultSetImpl method realClose.
@Override
public void realClose(boolean calledExplicitly) throws SQLException {
JdbcConnection locallyScopedConn = this.connection;
if (locallyScopedConn == null) {
// already closed
return;
}
synchronized (locallyScopedConn.getConnectionMutex()) {
// additional check in case ResultSet was closed while current thread was waiting for lock
if (this.isClosed) {
return;
}
try {
if (this.useUsageAdvisor) {
if (!calledExplicitly) {
this.eventSink.processEvent(ProfilerEvent.TYPE_USAGE, this.session, this.owningStatement, this, 0, new Throwable(), Messages.getString("ResultSet.ResultSet_implicitly_closed_by_driver"));
}
int resultSetSizeThreshold = locallyScopedConn.getPropertySet().getIntegerProperty(PropertyKey.resultSetSizeThreshold).getValue();
if (this.rowData.size() > resultSetSizeThreshold) {
this.eventSink.processEvent(ProfilerEvent.TYPE_USAGE, this.session, this.owningStatement, this, 0, new Throwable(), Messages.getString("ResultSet.Too_Large_Result_Set", new Object[] { Integer.valueOf(this.rowData.size()), Integer.valueOf(resultSetSizeThreshold) }));
}
if (!isLast() && !isAfterLast() && (this.rowData.size() != 0)) {
this.eventSink.processEvent(ProfilerEvent.TYPE_USAGE, this.session, this.owningStatement, this, 0, new Throwable(), Messages.getString("ResultSet.Possible_incomplete_traversal_of_result_set", new Object[] { Integer.valueOf(getRow()), Integer.valueOf(this.rowData.size()) }));
}
// Report on any columns that were selected but not referenced
if (this.columnUsed.length > 0 && !this.rowData.wasEmpty()) {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < this.columnUsed.length; i++) {
if (!this.columnUsed[i]) {
if (buf.length() > 0) {
buf.append(", ");
}
buf.append(this.columnDefinition.getFields()[i].getFullName());
}
}
if (buf.length() > 0) {
this.eventSink.processEvent(ProfilerEvent.TYPE_USAGE, this.session, this.owningStatement, this, 0, new Throwable(), Messages.getString("ResultSet.The_following_columns_were_never_referenced", new String[] { buf.toString() }));
}
}
}
} finally {
if (this.owningStatement != null && calledExplicitly) {
this.owningStatement.removeOpenResultSet(this);
}
SQLException exceptionDuringClose = null;
if (this.rowData != null) {
try {
this.rowData.close();
} catch (CJException sqlEx) {
exceptionDuringClose = SQLExceptionsMapping.translateException(sqlEx);
}
}
if (this.statementUsedForFetchingRows != null) {
try {
this.statementUsedForFetchingRows.realClose(true, false);
} catch (SQLException sqlEx) {
if (exceptionDuringClose != null) {
exceptionDuringClose.setNextException(sqlEx);
} else {
exceptionDuringClose = sqlEx;
}
}
}
this.rowData = null;
this.columnDefinition = null;
this.eventSink = null;
this.warningChain = null;
this.owningStatement = null;
this.db = null;
this.serverInfo = null;
this.thisRow = null;
this.fastDefaultCal = null;
this.fastClientCal = null;
this.connection = null;
this.session = null;
this.isClosed = true;
if (exceptionDuringClose != null) {
throw exceptionDuringClose;
}
}
}
}
Aggregations