Write Text Data to Oracle in Java
【Question】
I need to write a several-million-rows text file to Oracle. I have done it using the database’s SQLLDR. But I still want to do it in Java. Is there any idea about this?
【Answer】
SPL (Structured Process Language) is equipped with related class library to do this effortlessly. It generates simple script through various options designed for handling large files, column retrieval, separator selection and appending only situation. And it can be easily invoked from a Java application。
A |
B |
|
1 |
=file("E:\\source.txt").cursor() |
|
2 |
for A1,100000 |
|
3 |
>db.update(A2,tableName,col1,col2) |
A1: Import the text file as a cursor;
A2: Fetch one hundred thousand rows each time from the cursor;
A3: Write the fetched rows to Oracle database.
Since the I/O performance of JDBC is low, the whole-Java SPL solution is weaker in performance. But it is easy to migrate and manage.
About how to integrate an SPL script with a Java application, refer to How to Call an SPL Script in Java.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL