简体   繁体   English

Java导致OutOfMemory异常堆大小错误

[英]Java causing OutOfMemory exception heap size error

I want to know how to pass large data to Oracle PL/SQL procedure from a Java class. 我想知道如何从Java类将大数据传递给Oracle PL / SQL过程。 I am having around 1,500,000 records in file and I want to save it in the database. 我的文件中有大约1,500,000条记录,我想将其保存在数据库中。

Currently I am parsing the file making the collection and sending the ARRAY to the PL/SQL procedure but while making the Oracle ARRAY I am getting the OutOfMemoryError: Java heap size exception. 当前,我正在解析文件进行收集,并将ARRAY发送到PL / SQL过程,但是在创建Oracle ARRAY时,我收到OutOfMemoryError: Java heap size异常。

Kindly suggest how to get rid of this situation. 请提出如何摆脱这种情况。

I don't have enough knowledge in Oracle. 我对Oracle没有足够的了解。 However you can consider the below idea 但是您可以考虑以下想法

You can try to read data line by line from file instead of read at once and then move your record into your database as read. 您可以尝试从文件逐行读取数据,而不是一次读取,然后将记录以读取状态移到数据库中。

How to read a large text file line by line using Java? 如何使用Java逐行读取大文本文件?

If you want to move data at once to PL SQL, there should be option in Oracle like select into query to save data as collection and process it further. 如果要立即将数据移动到PL SQL,则Oracle中应该有一个选项,例如select into query,将数据保存为集合并进一步处理。

https://docs.oracle.com/cd/B14117_01/appdev.101/b10807/13_elems045.htm https://docs.oracle.com/cd/B14117_01/appdev.101/b10807/13_elems045.htm

Just found the solution of CLOB variable - a Character Large OBject is a collection of character data. 刚刚找到CLOB变量的解决方案-字符大对象是字符数据的集合。 I am using the CLOB variable in Java and reading the entire file and inserting it in a temporary table. 我在Java中使用CLOB变量,并读取整个文件并将其插入临时表中。 And from stored procedure I am reading that variable. 从存储过程中,我正在读取该变量。

Here is the demo: 这是演示:

http://www.idevelopment.info/data/Programming/java/jdbc/LOBS/CLOBFileExample.java http://www.idevelopment.info/data/Programming/java/jdbc/LOBS/CLOBFileExample.java

Thanks. 谢谢。

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

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