@@ -478,6 +478,8 @@ protected void implicitlyCloseAllOpenResults() throws SQLException {
478478 this .generatedKeysResults .doClose (CloseOption .IMPLICIT );
479479 }
480480 closeAllOpenResults ();
481+ this .results = null ;
482+ this .generatedKeysResults = null ;
481483 }
482484 }
483485
@@ -1060,7 +1062,6 @@ private long[] executeBatchUsingMultiQueries(long individualStatementTimeout) th
10601062 int escapeAdjust = 1 ;
10611063
10621064 batchStmt .setEscapeProcessing (this .doEscapeProcessing );
1063-
10641065 if (this .doEscapeProcessing ) {
10651066 escapeAdjust = 2 ; // We assume packet _could_ grow by this amount, as we're not sure how big statement will end up after escape processing
10661067 }
@@ -1143,6 +1144,7 @@ protected int processMultiCountsAndKeys(StatementImpl batchedStatement, int upda
11431144 connectionLock .lock ();
11441145 try {
11451146 updateCounts [updateCountCounter ++] = batchedStatement .getLargeUpdateCount ();
1147+ this .updateCount = batchedStatement .getLargeUpdateCount ();
11461148
11471149 boolean doGenKeys = this .batchedGeneratedKeys != null ;
11481150
@@ -1158,6 +1160,7 @@ protected int processMultiCountsAndKeys(StatementImpl batchedStatement, int upda
11581160
11591161 while (batchedStatement .getMoreResults () || batchedStatement .getLargeUpdateCount () != -1 ) {
11601162 updateCounts [updateCountCounter ++] = batchedStatement .getLargeUpdateCount ();
1163+ this .updateCount = batchedStatement .getLargeUpdateCount ();
11611164
11621165 if (doGenKeys ) {
11631166 long generatedKey = batchedStatement .getLastInsertID ();
@@ -1648,31 +1651,6 @@ public long getLastInsertID() {
16481651 }
16491652 }
16501653
1651- /**
1652- * getLongUpdateCount returns the current result as an update count, if the
1653- * result is a ResultSet or there are no more results, -1 is returned. It
1654- * should only be called once per result.
1655- *
1656- * <p>
1657- * This method returns longs as MySQL server returns 64-bit values for update counts
1658- * </p>
1659- *
1660- * @return the current update count.
1661- */
1662- public long getLongUpdateCount () {
1663- Lock connectionLock = checkClosed ().getConnectionLock ();
1664- connectionLock .lock ();
1665- try {
1666- if (this .results == null || this .results .hasRows ()) {
1667- return -1 ;
1668- }
1669-
1670- return this .updateCount ;
1671- } finally {
1672- connectionLock .unlock ();
1673- }
1674- }
1675-
16761654 @ Override
16771655 public int getMaxFieldSize () throws SQLException {
16781656 Lock connectionLock = checkClosed ().getConnectionLock ();
@@ -2349,11 +2327,11 @@ public long getLargeUpdateCount() throws SQLException {
23492327 Lock connectionLock = checkClosed ().getConnectionLock ();
23502328 connectionLock .lock ();
23512329 try {
2352- if (this .results == null || this . results . hasRows () ) {
2353- return - 1 ;
2330+ if (this .results != null ) {
2331+ return this . results . hasRows () ? - 1 : this . results . getUpdateCount () ;
23542332 }
23552333
2356- return this .results . getUpdateCount () ;
2334+ return this .updateCount ;
23572335 } finally {
23582336 connectionLock .unlock ();
23592337 }
0 commit comments