简体   繁体   English

executeBatch JDBC的堆大小错误

[英]Heapsize error with executeBatch JDBC

I'm using addBatch / executeBatch to insert some records in Oracle database table, but I've encountered the following heapsize error 我正在使用addBatch / executeBatch在Oracle数据库表中插入一些记录,但遇到以下堆大小错误

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.lang.reflect.Array.newArray(Native Method)
    at java.lang.reflect.Array.newInstance(Array.java:52)
    at oracle.jdbc.driver.BufferCache.get(BufferCache.java:212)
    at oracle.jdbc.driver.PhysicalConnection.getCharBuffer(PhysicalConnection.java:7422)
    at oracle.jdbc.driver.OraclePreparedStatement.setupBindBuffers(OraclePreparedStatement.java:2826)
    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9973)
    at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:213)

I've added the following parameter 我添加了以下参数

-Xms1024m -Xmx1024m

while calling the program with no luck. 却没有运气地调用该程序。 Adding the 1024m was fine for 180k records but it keeps crashing at 290k. 添加1024m可以存储18万条记录,但仍会导致290k崩溃。 I tried to increase it to 4024m but it does not help. 我试图将其增加到4024m,但没有帮助。

For every setting of the memory parameter you will find a record number that will fail. 对于memory参数的每个设置,您都会找到一个失败的记录号。

Divide the rows in blocks of a manageable size and issue after adding of each block 在添加每个块之后,将行划分为大小可管理的块,并发布

 sendBatch()

In Oracle you may also set 在Oracle中,您还可以设置

setExecuteBatch(blockSize)  

where blockSize is the number of rows that will be passed in each roundtrip. 其中, blockSize是每次往返传递的行数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM