赞
踩
我正在开发一个使用大型MySQL表的spring应用程序。当加载大表时,我得到一个OutOfMemoryException,因为驱动程序尝试将整个表加载到应用程序内存中。
我试过使用
statement.setFetchSize(Integer.MIN_VALUE);
但随后每个ResultSet我打开挂在close();看上去我发现,这是因为它尝试加载任何未读的行,然后关闭ResultSet,但是不是这样,因为我这样做:
ResultSet existingRecords = getTableData(tablename);
try {
while (existingRecords.next()) {
// ...
}
} finally {
existingRecords.close(); // this line is hanging, and there was no exception in the try clause
}
挂起发生在小表(3行),如果我不关闭RecordSet(发生在一个方法),然后connection.close()挂起。
堆栈跟踪挂起:
SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int) line: not available [native method]
SocketInputStream.read(byte[], int, int) line: 129
ReadAheadInputStream.fill(int) line: 113
ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(byte[], int, int) line: 160
ReadAheadInputStream.read(byte[], int, int) line: 188
MysqlIO.readFully(InputStream, byte[], int, int) line: 2428
MysqlIO.reuseAndReadPacket(Buffer, int) line: 2882
MysqlIO.reuseAndReadPacket(Buffer) line: 2871
MysqlIO.checkErrorPacket(int) line: 3414
MysqlIO.checkErrorPacket() line: 910
MysqlIO.nextRow(Field[], int, boolean, int, boolean, boolean, boolean, Buffer) line: 1405
RowDataDynamic.nextRecord() line: 413
RowDataDynamic.next() line: 392
RowDataDynamic.close() line: 170
JDBC4ResultSet(ResultSetImpl).realClose(boolean) line: 7473
JDBC4ResultSet(ResultSetImpl).close() line: 881
DelegatingResultSet.close() line: 152
DelegatingResultSet.close() line: 152
DelegatingPreparedStatement(DelegatingStatement).close() line: 163
(This is my class) Database.close() line: 84
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。