executeBatch JDBC 的堆大小錯誤 (Heapsize error with executeBatch JDBC)


問題描述

executeBatch JDBC 的堆大小錯誤 (Heapsize error with executeBatch JDBC)

我正在使用addBatch / executeBatch在Oracle數據庫表中插入一些記錄,但是我遇到了以下heapsize錯誤

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)

我添加了以下參數

‑Xms1024m ‑Xmx1024m

在沒有運氣的情況下調用程序。添加 1024m 對於 180k 記錄來說很好,但它一直在 290k 崩潰。我嘗試將其增加到 4024m,但沒有幫助。


參考解法

方法 1:

For every setting of the memory parameter you will find a record number that will fail.

Divide the rows in blocks of a manageable size and issue after adding of each block

 sendBatch()

In Oracle you may also set

setExecuteBatch(blockSize)  

where blockSizeis the number of rows that will be passed in each roundtrip.

(by Mr. HMarmite Bomber)

參考文件

  1. Heapsize error with executeBatch JDBC (CC BY‑SA 2.5/3.0/4.0)

#jdbc #java #heap-memory






相關問題

在不啟動事務的情況下通過 Hibernate 對 MySQL 數據庫運行查詢意味著什麼? (What are the implications of running a query against a MySQL database via Hibernate without starting a transaction?)

Праблема з заявай аб абнаўленні Java (Java Update statement issue)

我的 Jar 應用程序(myapplication.jar + Mysql 連接器)在其他計算機上不起作用 (My Jar application(myapplication.jar + Mysql connector) doesnt work on other computer)

executeBatch JDBC 的堆大小錯誤 (Heapsize error with executeBatch JDBC)

格式為“07-apr-2016”的 Java 日期字符串在轉換為 sqldate 時會產生錯誤的結果 (A Java date string in the format "07-apr-2016" produces wrong result when converted to sqldate)

SQLite 中的臨時內存數據庫 (Temporary in-memory database in SQLite)

Websphere 6.1 中的 SQL 日誌記錄 (SQL logging in Websphere 6.1)

我在哪裡可以下載 MySQL Connector/J 的源代碼 (Where can I download source for MySQL Connector/J)

'用戶必須在 weblogic 重新啟動時提供 JDBC 連接' ('The user must supply a JDBC connection' on weblogic restart)

配置 Jetty 6 以使用 commons.dbcp 數據源 (Configuring Jetty 6 to use commons.dbcp datasource)

在netbeans上訪問mysql (Access mysql on netbeans)

spark中的jdbc更新語句 (Jdbc update statement in spark)







留言討論