Skip to content

Commit 829321f

Browse files
Added cleanup task to start of every execute. (#2272)
* Initial commit. Add the cleanup task to any execute task to clean up on execute. * Remove added lines in test file * Remove added imports * Quick test fix try * Line should be removed, not just commented out. * Added missing execute cases * Discarded count should always be 1 * Mistake revert * Another try * Reverted test changes to try to get some consistency
1 parent 5f71d60 commit 829321f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ public java.sql.ResultSet executeQuery() throws SQLServerException, SQLTimeoutEx
487487
loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getCurrent().toString());
488488
}
489489
checkClosed();
490+
connection.unprepareUnreferencedPreparedStatementHandles(false);
490491
executeStatement(new PrepStmtExecCmd(this, EXECUTE_QUERY));
491492
loggerExternal.exiting(getClassNameLogging(), "executeQuery");
492493
return resultSet;
@@ -501,6 +502,7 @@ public java.sql.ResultSet executeQuery() throws SQLServerException, SQLTimeoutEx
501502
*/
502503
final java.sql.ResultSet executeQueryInternal() throws SQLServerException, SQLTimeoutException {
503504
checkClosed();
505+
connection.unprepareUnreferencedPreparedStatementHandles(false);
504506
executeStatement(new PrepStmtExecCmd(this, EXECUTE_QUERY_INTERNAL));
505507
return resultSet;
506508
}
@@ -513,7 +515,7 @@ public int executeUpdate() throws SQLServerException, SQLTimeoutException {
513515
}
514516

515517
checkClosed();
516-
518+
connection.unprepareUnreferencedPreparedStatementHandles(false);
517519
executeStatement(new PrepStmtExecCmd(this, EXECUTE_UPDATE));
518520

519521
// this shouldn't happen, caller probably meant to call executeLargeUpdate
@@ -534,6 +536,7 @@ public long executeLargeUpdate() throws SQLServerException, SQLTimeoutException
534536
loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getCurrent().toString());
535537
}
536538
checkClosed();
539+
connection.unprepareUnreferencedPreparedStatementHandles(false);
537540
executeStatement(new PrepStmtExecCmd(this, EXECUTE_UPDATE));
538541
loggerExternal.exiting(getClassNameLogging(), "executeLargeUpdate", updateCount);
539542
return updateCount;
@@ -546,6 +549,7 @@ public boolean execute() throws SQLServerException, SQLTimeoutException {
546549
loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getCurrent().toString());
547550
}
548551
checkClosed();
552+
connection.unprepareUnreferencedPreparedStatementHandles(false);
549553
executeStatement(new PrepStmtExecCmd(this, EXECUTE));
550554
loggerExternal.exiting(getClassNameLogging(), "execute", null != resultSet);
551555
return null != resultSet;
@@ -2199,6 +2203,7 @@ public int[] executeBatch() throws SQLServerException, BatchUpdateException, SQL
21992203
loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getCurrent().toString());
22002204
}
22012205
checkClosed();
2206+
connection.unprepareUnreferencedPreparedStatementHandles(false);
22022207
discardLastExecutionResults();
22032208

22042209
try {
@@ -2382,6 +2387,7 @@ public long[] executeLargeBatch() throws SQLServerException, BatchUpdateExceptio
23822387
loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getCurrent().toString());
23832388
}
23842389
checkClosed();
2390+
connection.unprepareUnreferencedPreparedStatementHandles(false);
23852391
discardLastExecutionResults();
23862392

23872393
try {

0 commit comments

Comments
 (0)