The export of data in Oracle is implemented with SQLPLUS spool. The import of batch data is achieved by SQLLOAD. The exported part of a large amount of data is as follows: / ************************** * SQL script part demo.sql begin ******* ****************** // *********************************** * @author Meconsea * @date 20050413 * @msn meconsea@hotmail.com * @Email mechan*****************************************************
// ## - Markup HTML: HTML format output, default is OFF
// ## - AutoCommit: Automatically submit record changes in INSERT, UPDATE, DELETE, default is OFF
// ## - define: Identify the variable preamble in the command, default is ON, which is '&', touch the variable preamble, the back string as a variable process.
Set colsep ''; // ## - domain output separator
Set echo off; // ## - Display each SQL command in the START startup script, default is ON
SET feedback off; // ## - The number of records processed back to this SQL command, the default is ON
Set heading off; // ## - Output domain title, default is ON
SET PAGESIZE 0; // ## - Outputs the number of rows per page, default is 24, in order to avoid paging, can be set to 0.
Set linesize 80; // ## - Output a line of characters, default is 80
Set NumWidth 12; // ## - Output Number Type Length, default 10
SET TERMOUT OFF; / / ## - Show the execution result of the command in the script, default is ON
SET TIMING OFF; // ## - Show the time consumption of each SQL command, default is OFF
Set trimout on; // ## - Remove the standard output of the trailing space of each row, default is OFF
Set trimspool on; // ## - Remove Redirection (spool) Output of the trailing space of each row, default is OFF
Spool c: /data/dmczry.txt;
SELECT TRIM (CZRY_DM), TRIM (SWJG_DM), TRIM (CZRY_MC) from DM_CZRY;
Spool OFF;
EOF
/ ********************** * DEMO.SQL END ****************************** ** / Use sqlload when data imports, use Java to call SQLLOAD when calling. Sqlload includes a CTL control file. For example: / ******************** * Meconsea ctl ******************* / LOAD DATA Infile 'c: /data/dmczry.txt' Replace INTO TABLE DM_CZRY FIELDS TERMINATED BY X'09 '(CZRY_DM, SWJG_DM, CZRY_MC) / **************************** * END * Note: The replace inside can be changed to the append ****************** / JAVA program as follows: In the Java program, it can be written as a BAT file according to the needs. Write the path of the database configured and files to a Properties file. / *********************** * IDE Properties ***************************** *** / dserver = test / test @ sjjzsqlldr = d: //racle//ora92//bin/sqlldr.exectldmczry=c: //data/rmczry=c: // Data // DMCZRY.TXT
Write a PropertyBean.java to manipulate the Properties file. (Lazy is not written!) Import the record into DB with DMCZRY.java. Part of the code is as follows:
/ **************************************************************************************************************************************************************************************************************************************** ********** / ............ sqlldr = pb.getsqlldr (); txt = pb.getxtddmczry (); CTL = Pb.getctLDMCZRY (); DSERVER = pb.getdserver (); process processcmd = runtime.getRuntime (). EXEC (SQLLDR " cmdstr); ...........