Skip to content

Commit 78fbabd

Browse files
author
youyou.dyy
committed
fix queryCusor() fails in streaming mode of MySQL Connector/J (fetchSize=Integer.MIN_VALUE) #1654
1 parent 50751a3 commit 78fbabd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/main/java/org/apache/ibatis/executor/BatchExecutor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ protected <E> Cursor<E> doQueryCursor(MappedStatement ms, Object parameter, RowB
102102
StatementHandler handler = configuration.newStatementHandler(wrapper, ms, parameter, rowBounds, null, boundSql);
103103
Connection connection = getConnection(ms.getStatementLog());
104104
Statement stmt = handler.prepare(connection, transaction.getTimeout());
105-
stmt.closeOnCompletion();
106105
handler.parameterize(stmt);
107-
return handler.queryCursor(stmt);
106+
Cursor<E> cursor = handler.queryCursor(stmt);
107+
stmt.closeOnCompletion();
108+
return cursor;
108109
}
109110

110111
@Override

src/main/java/org/apache/ibatis/executor/SimpleExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ protected <E> Cursor<E> doQueryCursor(MappedStatement ms, Object parameter, RowB
7171
Configuration configuration = ms.getConfiguration();
7272
StatementHandler handler = configuration.newStatementHandler(wrapper, ms, parameter, rowBounds, null, boundSql);
7373
Statement stmt = prepareStatement(handler, ms.getStatementLog());
74+
Cursor<E> cursor = handler.queryCursor(stmt);
7475
stmt.closeOnCompletion();
75-
return handler.queryCursor(stmt);
76+
return cursor;
7677
}
7778

7879
@Override

0 commit comments

Comments
 (0)