Skip to content

Commit 344e6d2

Browse files
authored
Fixed intermittent null prepared statement handle (#1886)
1 parent ea02095 commit 344e6d2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2910,7 +2910,12 @@ final void doExecutePreparedStatementBatch(PrepStmtBatchExecCmd batchCommand) th
29102910
if (!getNextResult(true))
29112911
return;
29122912

2913-
if (isSpPrepareExecuted) {
2913+
// If sp_prepare was executed, but a handle doesn't exist that means
2914+
// the TDS response for sp_prepare has not been processed yet. Rather, it means
2915+
// that another result was processed from a sp_execute query instead. Therefore, we
2916+
// skip the if-block below and continue until the handle is set from the processed
2917+
// sp_prepare TDS response.
2918+
if (isSpPrepareExecuted && hasPreparedStatementHandle()) {
29142919
isSpPrepareExecuted = false;
29152920
resetForReexecute();
29162921
tdsWriter = batchCommand.startRequest(TDS.PKT_RPC);

0 commit comments

Comments
 (0)