--- /dev/null
+package com.rapide_act;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.io.PrintWriter;
+import java.util.Date;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.math.BigDecimal;
+
+public class CmnProperty{
+ protected String database = null;
+ protected static final int DB_TYPE_ORACLE = 0;
+ protected static final int DB_TYPE_SQLSERVER = 1;
+ protected static final int DB_TYPE_DB2 = 2;
+ protected static final int DB_TYPE_MYSQL = 3;
+ protected static final int DB_TYPE_POSTGRESQL = 4;
+ protected static final int DB_TYPE_UNKNOWN = -1;
+ protected static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"};
+ protected static final int MASK_PTN_ALL = 0;
+ protected static final int MASK_PTN_ALT = 1;
+ protected static final int MASK_PTN_EDGE = 2;
+ protected static final int D_USER = 0;
+ protected static final int D_PASS = 1;
+ protected static final int D_URL = 2;
+ protected static final int D_DRIVER = 3;
+ protected static final int D_OUTPUT = 4;
+ protected static final int D_INPUT = 5;
+ protected static final int D_LINESEP = 6;
+ protected static final int D_INLINESEP = 7;
+ protected static final int D_FILENCODE = 8;
+ protected static final int D_NULLMARK = 9;
+ protected static final int D_DELIMITER = 10;
+ protected static final int D_TBLSQL = 11;
+ protected static final int D_TBLKEYSQL = 12;
+ protected static final int D_ORDER = 13;
+ protected static final int D_QUOTATION = 14;
+ protected static final int D_BATCOUNT = 15;
+ protected static final int D_INCLTAB = 16;
+ protected static final int D_EXCLTAB = 17;
+ protected static final int D_INCLCOL = 18;
+ protected static final int D_EXCLCOL = 19;
+ protected static final int D_INCLCOLMASK = 20;
+ protected static final int D_EXCLCOLMASK = 21;
+ protected static final int D_SBYTEMASKCHR = 22;
+ protected static final int D_DBYTEMASKCHR = 23;
+ protected static final int D_MASKPTN = 24;
+ protected static final int D_PROPFILE = 25;
+ protected static final int KEYS = 26;
+ protected static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm",
+ "dm","ts","tks","od","qt","bc","it","et","ic","ec",
+ "icm","ecm","smc","dmc","mp","pf"};
+
+ protected String [] prop_val = new String[KEYS];
+ protected static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
+ protected static final String DEFAULT_IN_FOLDER = "input";
+ protected static final String DEFAULT_PROP_FILE = "RapideLoader.properties";
+ protected static String [] tSqlArray = {
+ "select "
+ + " table_name "
+ + " from user_tables "
+ + " order by table_name",
+ "select "
+ + " name as table_name "
+ + " from sys.tables "
+ + " order by name"
+ };
+ protected static String [] tkSqlArray = {
+ "select "
+ + "a.table_name,"
+ + "d.column_name "
+ + " from user_tables a,"
+ + " (select b.table_name, "
+ + " c.column_name, "
+ + " c.position "
+ + " from user_constraints b, "
+ + " user_cons_columns c "
+ + " where b.CONSTRAINT_TYPE = 'P' and "
+ + " b.TABLE_NAME = c.TABLE_NAME and "
+ + " b.CONSTRAINT_NAME = c.CONSTRAINT_NAME "
+ + " ) d "
+ + "where a.table_name = d.table_name(+) "
+ + "order by a.table_name, d.position",
+ "SELECT "
+ + " A.name AS table_name, "
+ + " D.name AS col_name "
+ + "FROM sys.tables AS A "
+ + "LEFT OUTER JOIN sys.key_constraints AS B "
+ + "ON A.object_id = B.parent_object_id "
+ + " AND B.type = 'PK' "
+ + "LEFT OUTER JOIN sys.index_columns AS C "
+ + "ON B.parent_object_id = C.object_id "
+ + " AND B.unique_index_id = C.index_id "
+ + "LEFT OUTER JOIN sys.columns AS D "
+ + "ON C.object_id = D.object_id "
+ + " AND C.column_id = D.column_id "
+ + "order by A.name,C.key_ordinal"
+ };
+
+ protected String user = null;
+ protected String pass = null;
+ protected String url = null;
+ protected String driver = null;
+ protected String outFolder = null;
+ protected String inFolder = null;
+ protected String lineSeparator = System.getProperty("line.separator");
+ protected String inColLineSeparator = System.getProperty("line.separator");
+ protected String fileEncoding = System.getProperty("file.encoding");
+ protected String nullMark = "";
+ protected String delimiter = "\t";
+ protected String tSql = null;
+ protected String tkSql = null;
+ protected boolean isOrder = false;
+ protected boolean isQuotation = true;
+ protected int batchCount = 1000;
+ protected String inclTables = null;
+ protected String exclTables = null;
+ protected String inclCols = null;
+ protected String exclCols = null;
+ protected String inclColsMask = null;
+ protected String exclColsMask = null;
+ protected char singleByteMaskChar = '*';
+ protected char doubleByteMaskChar = '\u25A0';
+ protected String maskPattern = "ALT";
+
+ protected String [] inclTablesArray = null;
+ protected String [] exclTablesArray = null;
+ protected String [] inclColsArray = null;
+ protected String [] exclColsArray = null;
+ protected String [] inclColsMaskArray = null;
+ protected String [] exclColsMaskArray = null;
+ protected boolean isInclTables = false;
+ protected boolean isExclTables = false;
+ protected boolean isInclCols = false;
+ protected boolean isExclCols = false;
+ protected boolean isMask = false;
+ protected boolean isInclColsMask = false;
+ protected boolean isExclColsMask = false;
+ protected int dbType = DB_TYPE_UNKNOWN;
+
+ protected void getProperties(String _propFile) throws Exception{
+ BufferedReader br = null;
+ Properties prop = null;
+ try {
+ prop = new Properties();
+ br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(_propFile), "UTF-8"));
+ prop.load(br);
+ for(int i=0;i<KEYS;i++){
+ prop_val[i] = prop.getProperty(database + "." +PROP_KEY[i]);
+ }
+ br.close();
+ br = null;
+ } catch (NullPointerException e) {
+ throw new Exception("Property File (" + _propFile +") Not Found");
+ } catch (IOException e) {
+ throw e;
+ }
+ finally{
+ try {
+ if (br != null) {
+ br.close();
+ br = null;
+ }
+ }
+ catch (IOException e) {
+ throw e;
+ }
+ }
+ }
+
+
+ CmnProperty() {
+ super();
+ }
+
+ protected void setProperty(String _database) throws Exception{
+ database = _database;
+ if(database != null){
+ if(!CmnUtils.isEmpty(prop_val[D_PROPFILE])){
+ getProperties(System.getProperty(prop_val[D_PROPFILE]));
+ } else {
+ getProperties(DEFAULT_PROP_FILE);
+ }
+ }
+
+ for(int i=0;i<KEYS;i++){
+ if(System.getProperty(PROP_KEY[i])!=null)prop_val[i] = System.getProperty(PROP_KEY[i]);
+ CmnUtils.debugPrint(PROP_KEY[i] + "=" + prop_val[i]);
+ }
+
+ if(!CmnUtils.isEmpty(prop_val[D_USER]))user = prop_val[D_USER];
+ if(!CmnUtils.isEmpty(prop_val[D_PASS]))pass = prop_val[D_PASS];
+ if(!CmnUtils.isEmpty(prop_val[D_URL]))url = prop_val[D_URL];
+ if(!CmnUtils.isEmpty(prop_val[D_DRIVER]))driver = prop_val[D_DRIVER];
+ if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT];
+ if(!CmnUtils.isEmpty(prop_val[D_INPUT]))inFolder = prop_val[D_INPUT];
+ if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]);
+ if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))inColLineSeparator = CmnUtils.getLineSeparator(prop_val[D_INLINESEP]);
+ if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE];
+ if(!CmnUtils.isEmpty(prop_val[D_NULLMARK]))nullMark = prop_val[D_NULLMARK];
+ if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]);
+ if(!CmnUtils.isEmpty(prop_val[D_TBLSQL]))tSql = prop_val[D_TBLSQL];
+ if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL]))tkSql = prop_val[D_TBLKEYSQL];
+ if(!CmnUtils.isEmpty(prop_val[D_ORDER]) && prop_val[D_ORDER].toUpperCase().equals("Y"))isOrder = true;
+ if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]) && prop_val[D_QUOTATION].toUpperCase().equals("N"))isQuotation = false;
+ if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))batchCount = Integer.parseInt(prop_val[D_BATCOUNT]);
+ if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))isInclTables = true;
+ if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))isExclTables = true;
+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))isInclCols = true;
+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))isExclCols = true;
+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))isInclColsMask = true;
+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))isExclColsMask = true;
+ if(isInclColsMask || isExclColsMask)isMask = true;
+ if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTables = prop_val[D_INCLTAB].toUpperCase();
+ if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTables = prop_val[D_EXCLTAB].toUpperCase();
+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclCols = prop_val[D_INCLCOL].toUpperCase();
+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclCols = prop_val[D_EXCLCOL].toUpperCase();
+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMask = prop_val[D_INCLCOLMASK].toUpperCase();
+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMask = prop_val[D_EXCLCOLMASK].toUpperCase();
+ if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTablesArray = CmnUtils.splitCsv(prop_val[D_INCLTAB].toUpperCase());
+ if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTablesArray = CmnUtils.splitCsv(prop_val[D_EXCLTAB].toUpperCase());
+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclColsArray = CmnUtils.splitCsv(prop_val[D_INCLCOL].toUpperCase());
+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclColsArray = CmnUtils.splitCsv(prop_val[D_EXCLCOL].toUpperCase());
+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMaskArray = CmnUtils.splitCsv(prop_val[D_INCLCOLMASK].toUpperCase());
+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMaskArray = CmnUtils.splitCsv(prop_val[D_EXCLCOLMASK].toUpperCase());
+ if(!CmnUtils.isEmpty(prop_val[D_SBYTEMASKCHR]))singleByteMaskChar = prop_val[D_SBYTEMASKCHR].charAt(0);
+ if(!CmnUtils.isEmpty(prop_val[D_DBYTEMASKCHR]))doubleByteMaskChar = prop_val[D_DBYTEMASKCHR].charAt(0);
+ if(!CmnUtils.isEmpty(prop_val[D_MASKPTN]))maskPattern = prop_val[D_MASKPTN];
+
+ if(user == null){
+ throw new Exception("user is null");
+ } else if (pass == null){
+ throw new Exception("pass is null");
+ } else if (url == null){
+ throw new Exception("url is null");
+ } else if (driver == null){
+ throw new Exception("driver is null");
+ }
+
+ for(int i = 0;i<DB_TYPE_NAME.length;i++){
+ if (url.toUpperCase().contains(DB_TYPE_NAME[i])){
+ dbType = i;
+ break;
+ }
+ }
+
+ if (dbType != DB_TYPE_UNKNOWN){
+ if(!CmnUtils.isEmpty(prop_val[D_TBLSQL])){
+ tSql = prop_val[D_TBLSQL];
+ } else {
+ tSql = tSqlArray[dbType];
+ }
+ } else {
+ throw new Exception("dbtype unknown");
+ }
+
+ if (dbType != DB_TYPE_UNKNOWN){
+ if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL])){
+ tkSql = prop_val[D_TBLKEYSQL];
+ } else {
+ tkSql = tkSqlArray[dbType];
+ }
+ } else {
+ throw new Exception("dbtype unknown");
+ }
+
+ if(database!=null)CmnUtils.infoPrint("-->\91Î\8fÛ\83f\81[\83^\83x\81[\83X='" + database.toUpperCase() + "'");
+ if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))CmnUtils.infoPrint("-->\8bæ\90Ø\82è\95¶\8e\9a='" + prop_val[D_DELIMITER] + "'");
+ if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))CmnUtils.infoPrint("-->\89ü\8ds\83R\81[\83h='" + prop_val[D_LINESEP] + "'");
+ if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))CmnUtils.infoPrint("-->\83J\83\89\83\80\93à\89ü\8ds\83R\81[\83h='" + prop_val[D_INLINESEP] + "'");
+ if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))CmnUtils.infoPrint("-->\95¶\8e\9a\83R\81[\83h='" + prop_val[D_FILENCODE] + "'");
+ if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]))CmnUtils.infoPrint("-->\88ø\97p\8bå=" + CmnUtils.getYesNo(isQuotation));
+ if(!CmnUtils.isEmpty(prop_val[D_ORDER]))CmnUtils.infoPrint("-->\83\\81[\83g=" + CmnUtils.getYesNo(isOrder));
+ if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))CmnUtils.infoPrint("-->\83o\83b\83`\8f\88\97\9d\90\94=" + batchCount);
+ if(isInclTables)CmnUtils.infoPrint("-->\91Î\8fÛ\83e\81[\83u\83\8b='" + inclTables.toUpperCase() + "'");
+ if(isExclTables)CmnUtils.infoPrint("-->\8f\9c\8aO\83e\81[\83u\83\8b='" + exclTables.toUpperCase() + "'");
+ if(isInclCols)CmnUtils.infoPrint("-->\91Î\8fÛ\83J\83\89\83\80='" + inclCols.toUpperCase() + "'");
+ if(isExclCols)CmnUtils.infoPrint("-->\8f\9c\8aO\83J\83\89\83\80='" + exclCols.toUpperCase() + "'");
+ if(isMask){
+ CmnUtils.infoPrint("-->\83}\83X\83L\83\93\83O=" + CmnUtils.getYesNo(isMask));
+ CmnUtils.infoPrint("-->\83}\83X\83N\83L\83\93\83O\83p\83^\81[\83\93=" + maskPattern.toUpperCase());
+ CmnUtils.infoPrint("-->\94¼\8ap\83}\83X\83N\95¶\8e\9a='" + singleByteMaskChar + "'");
+ CmnUtils.infoPrint("-->\91S\8ap\83}\83X\83N\95¶\8e\9a='" + doubleByteMaskChar + "'");
+ if(isInclColsMask)CmnUtils.infoPrint("-->\83}\83X\83N\91Î\8fÛ\83J\83\89\83\80='" + inclColsMask.toUpperCase() + "'");
+ if(isExclColsMask)CmnUtils.infoPrint("-->\83}\83X\83N\8f\9c\8aO\83J\83\89\83\80='" + exclColsMask.toUpperCase() + "'");
+ }
+
+ }
+
+
+}
+
public class RapideLoader{
private String database = null;
- private String user = null;
- private String pass = null;
- private String url = null;
- private String driver = null;
- private String sql_table_list = null;
- private String sql_table_key_list = null;
- private static final int DB_TYPE_ORACLE = 0;
- private static final int DB_TYPE_SQLSERVER = 1;
- private static final int DB_TYPE_DB2 = 2;
- private static final int DB_TYPE_MYSQL = 3;
- private static final int DB_TYPE_POSTGRESQL = 4;
- private static final int DB_TYPE_UNKNOWN = -1;
- private static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"};
- private static final int MASK_PTN_ALL = 0;
- private static final int MASK_PTN_ALT = 1;
- private static final int MASK_PTN_EDGE = 2;
- private static final int D_USER = 0;
- private static final int D_PASS = 1;
- private static final int D_URL = 2;
- private static final int D_DRIVER = 3;
- private static final int D_OUTPUT = 4;
- private static final int D_INPUT = 5;
- private static final int D_LINESEP = 6;
- private static final int D_INLINESEP = 7;
- private static final int D_FILENCODE = 8;
- private static final int D_NULLMARK = 9;
- private static final int D_DELIMITER = 10;
- private static final int D_TBLSQL = 11;
- private static final int D_TBLKEYSQL = 12;
- private static final int D_ORDER = 13;
- private static final int D_QUOTATION = 14;
- private static final int D_BATCOUNT = 15;
- private static final int D_INCLTAB = 16;
- private static final int D_EXCLTAB = 17;
- private static final int D_INCLCOL = 18;
- private static final int D_EXCLCOL = 19;
- private static final int D_INCLCOLMASK = 20;
- private static final int D_EXCLCOLMASK = 21;
- private static final int D_SBYTEMASKCHR = 22;
- private static final int D_DBYTEMASKCHR = 23;
- private static final int D_MASKPTN = 24;
- private static final int D_PROPFILE = 25;
- private static final int KEYS = 26;
- private static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm",
- "dm","ts","tks","od","qt","bc","it","et","ic","ec",
- "icm","ecm","smc","dmc","mp","pf"};
- private String [] prop_val = new String[KEYS];
- private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
- private static final String DEFAULT_IN_FOLDER = "input";
- private static final String DEFAULT_PROP_FILE = "RapideLoader.properties";
- private static String [] sql_table_list_array = {
- "select "
- + " table_name "
- + " from user_tables "
- + " order by table_name",
- "select "
- + " name as table_name "
- + " from sys.tables "
- + " order by name"
- };
-
- private boolean isLob = false;
- private boolean isContinue = false;
- private String nullMark = "";
- private boolean isOrder = false;
- private boolean isQuotation = true;
- private int batchCount = 1000;
- private boolean isInclTables = false;
- private boolean isExclTables = false;
- private boolean isInclCols = false;
- private boolean isExclCols = false;
- private boolean isMask = false;
- private boolean isInclColsMask = false;
- private boolean isExclColsMask = false;
- private String delimiter = "\t";
- private String lineSeparator = System.getProperty("line.separator");
- private String inColLineSeparator = System.getProperty("line.separator");
- private String outFolder = null;
- private String inFolder = null;
- private String inclTables = null;
- private String exclTables = null;
- private String inclCols = null;
- private String exclCols = null;
- private String inclColsMask = null;
- private String exclColsMask = null;
- private String [] inclTablesArray = null;
- private String [] exclTablesArray = null;
- private String [] inclColsArray = null;
- private String [] exclColsArray = null;
- private String [] inclColsMaskArray = null;
- private String [] exclColsMaskArray = null;
- private char singleByteMaskChar = '*';
- private char doubleByteMaskChar = '\u25A0';
- private String maskPattern = "ALT";
- private String fileEncoding = System.getProperty("file.encoding");
-
public static void main(String args[]){
try {
if (args.length > 0){
rapideLoader.load();
}
} catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void getProperties(String _propFile) throws Exception{
- BufferedReader br = null;
- Properties prop = null;
- try {
- prop = new Properties();
- br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(_propFile), "UTF-8"));
- prop.load(br);
- for(int i=0;i<KEYS;i++){
- prop_val[i] = prop.getProperty(database + "." +PROP_KEY[i]);
+ try{
+ CmnUtils.errorPrint(e.toString());
+ e.printStackTrace();
+ } catch (Exception ee){
+ ee.printStackTrace();
}
- br.close();
- br = null;
- } catch (NullPointerException e) {
- throw new Exception("Property File (" + _propFile +") Not Found");
- } catch (IOException e) {
- throw e;
}
- finally{
- try {
- if (br != null) {
- br.close();
- br = null;
- }
- }
- catch (IOException e) {
- throw e;
- }
- }
}
BufferedReader br = null;
String sql_load = null;
String sql_insert = null;
- int dbType = DB_TYPE_UNKNOWN;
String strLine = null;
String strMltLine = null;
String tbName = null;
Integer [] isNullable = null;
Boolean [] colIncl = null;
- File fldr = null;
+ File folder = null;
ArrayList<String> alData = null;
ArrayList<String> alColName = null;
ArrayList<String> alColTypeName = null;
int tb_count = 0;
int tb_col_count = 0;
int fl_col_count = 0;
+ boolean isLob = false;
+ boolean isContinue = false;
-
-
-
- if(database != null){
- if(!CmnUtils.isEmpty(prop_val[D_PROPFILE])){
- getProperties(System.getProperty(prop_val[D_PROPFILE]));
- } else {
- getProperties(DEFAULT_PROP_FILE);
- }
- }
+ CmnProperty cp = new CmnProperty();
+ cp.setProperty(database);
- for(int i=0;i<KEYS;i++){
- if(System.getProperty(PROP_KEY[i])!=null)prop_val[i] = System.getProperty(PROP_KEY[i]);
- CmnUtils.debugPrint(PROP_KEY[i] + "=" + prop_val[i]);
- }
-
- if(!CmnUtils.isEmpty(prop_val[D_USER]))user = prop_val[D_USER];
- if(!CmnUtils.isEmpty(prop_val[D_PASS]))pass = prop_val[D_PASS];
- if(!CmnUtils.isEmpty(prop_val[D_URL]))url = prop_val[D_URL];
- if(!CmnUtils.isEmpty(prop_val[D_DRIVER]))driver = prop_val[D_DRIVER];
- if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT];
- if(!CmnUtils.isEmpty(prop_val[D_INPUT]))inFolder = prop_val[D_INPUT];
- if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]);
- if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))inColLineSeparator = CmnUtils.getLineSeparator(prop_val[D_INLINESEP]);
- if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE];
- if(!CmnUtils.isEmpty(prop_val[D_NULLMARK]))nullMark = prop_val[D_NULLMARK];
- if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]);
- if(!CmnUtils.isEmpty(prop_val[D_TBLSQL]))sql_table_list = prop_val[D_TBLSQL];
- if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL]))sql_table_key_list = prop_val[D_TBLKEYSQL];
- if(!CmnUtils.isEmpty(prop_val[D_ORDER]) && prop_val[D_ORDER].toUpperCase().equals("Y"))isOrder = true;
- if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]) && prop_val[D_QUOTATION].toUpperCase().equals("N"))isQuotation = false;
- if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))batchCount = Integer.parseInt(prop_val[D_BATCOUNT]);
- if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))isInclTables = true;
- if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))isExclTables = true;
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))isInclCols = true;
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))isExclCols = true;
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))isInclColsMask = true;
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))isExclColsMask = true;
- if(isInclColsMask || isExclColsMask)isMask = true;
- if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTables = prop_val[D_INCLTAB].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTables = prop_val[D_EXCLTAB].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclCols = prop_val[D_INCLCOL].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclCols = prop_val[D_EXCLCOL].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMask = prop_val[D_INCLCOLMASK].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMask = prop_val[D_EXCLCOLMASK].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTablesArray = CmnUtils.splitCsv(prop_val[D_INCLTAB].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTablesArray = CmnUtils.splitCsv(prop_val[D_EXCLTAB].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclColsArray = CmnUtils.splitCsv(prop_val[D_INCLCOL].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclColsArray = CmnUtils.splitCsv(prop_val[D_EXCLCOL].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMaskArray = CmnUtils.splitCsv(prop_val[D_INCLCOLMASK].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMaskArray = CmnUtils.splitCsv(prop_val[D_EXCLCOLMASK].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_SBYTEMASKCHR]))singleByteMaskChar = prop_val[D_SBYTEMASKCHR].charAt(0);
- if(!CmnUtils.isEmpty(prop_val[D_DBYTEMASKCHR]))doubleByteMaskChar = prop_val[D_DBYTEMASKCHR].charAt(0);
- if(!CmnUtils.isEmpty(prop_val[D_MASKPTN]))maskPattern = prop_val[D_MASKPTN];
-
- if(user == null){
- throw new Exception("user is null");
- } else if (pass == null){
- throw new Exception("pass is null");
- } else if (url == null){
- throw new Exception("url is null");
- } else if (driver == null){
- throw new Exception("driver is null");
- }
-
- for(int i = 0;i<DB_TYPE_NAME.length;i++){
- if (url.toUpperCase().contains(DB_TYPE_NAME[i])){
- dbType = i;
- break;
- }
- }
-
- if (dbType != DB_TYPE_UNKNOWN){
- if(!CmnUtils.isEmpty(prop_val[D_TBLSQL])){
- sql_table_list = prop_val[D_TBLSQL];
- } else {
- sql_table_list = sql_table_list_array[dbType];
- }
- } else {
- throw new Exception("dbtype unknown");
- }
-
- DataAccessObjects dao = new DataAccessObjects(user, pass, url, driver);
+ DataAccessObjects dao = new DataAccessObjects(cp.user, cp.pass, cp.url, cp.driver);
try {
conn = dao.connect();
conn.setAutoCommit(false);
- if(inFolder != null){
- fldr = new File(inFolder);
+ if(cp.inFolder != null){
+ folder = new File(cp.inFolder);
} else {
if (database != null){
- fldr = new File(DEFAULT_IN_FOLDER + "/" + database.toUpperCase());
+ folder = new File(cp.DEFAULT_IN_FOLDER + "/" + database.toUpperCase());
} else {
- fldr = new File(DEFAULT_IN_FOLDER + "/" + DB_TYPE_NAME[dbType].toUpperCase());
+ folder = new File(cp.DEFAULT_IN_FOLDER + "/" + cp.DB_TYPE_NAME[cp.dbType].toUpperCase());
}
}
- CmnUtils.infoPrint("-->\91Î\8fÛ\83f\81[\83^\83x\81[\83X='" + database.toUpperCase() + "'");
- CmnUtils.infoPrint("-->\93ü\97Í\8c³='" + fldr + "'");
- CmnUtils.infoPrint("-->\8bæ\90Ø\82è\95¶\8e\9a='" + delimiter + "'");
- CmnUtils.infoPrint("-->\83o\83b\83`\83J\83E\83\93\83g=" + batchCount);
- CmnUtils.infoPrint("-->\88ø\97p\8bå=" + CmnUtils.getYesNo(isQuotation));
- if(isInclTables)CmnUtils.infoPrint("-->\91Î\8fÛ\83e\81[\83u\83\8b='" + inclTables.toUpperCase() + "'");
- if(isExclTables)CmnUtils.infoPrint("-->\8f\9c\8aO\83e\81[\83u\83\8b='" + exclTables.toUpperCase() + "'");
- if(isInclCols)CmnUtils.infoPrint("-->\91Î\8fÛ\83J\83\89\83\80='" + inclCols.toUpperCase() + "'");
- if(isExclCols)CmnUtils.infoPrint("-->\8f\9c\8aO\83J\83\89\83\80='" + exclCols.toUpperCase() + "'");
- CmnUtils.infoPrint("-->\83}\83X\83L\83\93\83O=" + CmnUtils.getYesNo(isMask));
- if(isMask){
- CmnUtils.infoPrint("-->\83}\83X\83N\83L\83\93\83O\83p\83^\81[\83\93=" + maskPattern.toUpperCase());
- if(isInclColsMask)CmnUtils.infoPrint("-->\83}\83X\83N\91Î\8fÛ\83J\83\89\83\80='" + inclColsMask.toUpperCase() + "'");
- if(isExclColsMask)CmnUtils.infoPrint("-->\83}\83X\83N\8f\9c\8aO\83J\83\89\83\80='" + exclColsMask.toUpperCase() + "'");
- CmnUtils.infoPrint("-->\94¼\8ap\83}\83X\83N\95¶\8e\9a='" + singleByteMaskChar + "'");
- CmnUtils.infoPrint("-->\91S\8ap\83}\83X\83N\95¶\8e\9a='" + doubleByteMaskChar + "'");
- }
+ CmnUtils.infoPrint("-->\93ü\97Í\8c³='" + folder + "'");
CmnUtils.infoPrint("\83f\81[\83^\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82µ\82½\81B");
- dao.select(sql_table_list);
+ dao.select(cp.tSql);
alData = dao.getArrayList();
tb_count = dao.getColumnCount();
int tb_rec_count = 0;
int fl_rec_count = 0;
int ins_rec_count = 0;
int tb_fl_match_count = 0;
- File [] inFiles = fldr.listFiles();
+ File [] inFiles = folder.listFiles();
if(inFiles != null) {
for(int k=0;k<inFiles.length;k++){
flName = CmnUtils.splitDot(inFiles[k].getName());
TABLE_LOOP:
for(int i=0;i<alData.size();i++){
if(tbName.equals(alData.get(i))){
- if(isInclTables && !CmnUtils.isMatch(inclTablesArray,tbName.toUpperCase())){
- CmnUtils.debugPrint("inclTables=" + inclTables);
- CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(inclTablesArray,tbName.toUpperCase()));
+ if(cp.isInclTables && !CmnUtils.isMatch(cp.inclTablesArray,tbName.toUpperCase())){
+ CmnUtils.debugPrint("cp.inclTables=" + cp.inclTables);
+ CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(cp.inclTablesArray,tbName.toUpperCase()));
continue;
}
- if(isExclTables && CmnUtils.isMatch(exclTablesArray,tbName.toUpperCase())){
- CmnUtils.debugPrint("exclTables=" + exclTables);
- CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(exclTablesArray,tbName.toUpperCase()));
+ if(cp.isExclTables && CmnUtils.isMatch(cp.exclTablesArray,tbName.toUpperCase())){
+ CmnUtils.debugPrint("cp.exclTables=" + cp.exclTables);
+ CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(cp.exclTablesArray,tbName.toUpperCase()));
continue;
}
- br = new BufferedReader(new InputStreamReader(new FileInputStream(fldr + "/" + alData.get(i) + "." + flName[1]), fileEncoding));
+ br = new BufferedReader(new InputStreamReader(new FileInputStream(folder + "/" + alData.get(i) + "." + flName[1]), cp.fileEncoding));
sql_load = "select * from " + alData.get(i);
stmt = dao.prepareSql(sql_load);
dao.executeSql(stmt);
CmnUtils.debugPrint("LOB="+isLob);
while((strLine=br.readLine()) != null){
if (fl_rec_count == 0){
- if(isQuotation){
- colData = CmnUtils.split(strLine,"\"" + delimiter + "\"");
+ if(cp.isQuotation){
+ colData = CmnUtils.split(strLine,"\"" + cp.delimiter + "\"");
} else {
- colData = CmnUtils.split(strLine,delimiter);
+ colData = CmnUtils.split(strLine,cp.delimiter);
}
fl_col_count = colData.length;
fl_col_seq = new int[colData.length];
for(int j=0;j<colData.length;j++){
for(int l=0;l<tb_col_count;l++){
if(colName[l].equals(colData[j].replaceAll("\"",""))){
- if(isInclCols || isExclCols){
+ if(cp.isInclCols || cp.isExclCols){
if(
- (isInclCols &&
- !isExclCols &&
- CmnUtils.isMatch(inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
+ (cp.isInclCols &&
+ !cp.isExclCols &&
+ CmnUtils.isMatch(cp.inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
) ||
- (isInclCols &&
- isExclCols &&
- CmnUtils.isMatch(inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase()) &&
- !CmnUtils.isMatch(exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
+ (cp.isInclCols &&
+ cp.isExclCols &&
+ CmnUtils.isMatch(cp.inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase()) &&
+ !CmnUtils.isMatch(cp.exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
) ||
- (!isInclCols &&
- isExclCols &&
- !CmnUtils.isMatch(exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
+ (!cp.isInclCols &&
+ cp.isExclCols &&
+ !CmnUtils.isMatch(cp.exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
)
){
CmnUtils.debugPrint("\91Î\8fÛ\83J\83\89\83\80=" + colName[l].toUpperCase());
break TABLE_LOOP;
}
} else {
- if(isQuotation){
- colData = CmnUtils.split(strLine,"\"" + delimiter + "\"");
+ if(cp.isQuotation){
+ colData = CmnUtils.split(strLine,"\"" + cp.delimiter + "\"");
} else {
- colData = CmnUtils.split(strLine,delimiter);
+ colData = CmnUtils.split(strLine,cp.delimiter);
}
if(colData.length == fl_col_count){
if(!strMltLine.equals("")){
strMltLine += strLine;
isContinue = true;
} else {
- strMltLine += inColLineSeparator + strLine;
- if(isQuotation){
- colData = CmnUtils.split(strMltLine,"\"" + delimiter + "\"");
+ strMltLine += cp.inColLineSeparator + strLine;
+ if(cp.isQuotation){
+ colData = CmnUtils.split(strMltLine,"\"" + cp.delimiter + "\"");
} else {
- colData = CmnUtils.split(strMltLine,delimiter);
+ colData = CmnUtils.split(strMltLine,cp.delimiter);
}
if(colData.length == fl_col_count){
isContinue = false;
if(isContinue == false){
for(int j=0;j<ins_rec_count;j++){
if(j==0){
- if(isQuotation){
+ if(cp.isQuotation){
colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(1,colData[fl_col_seq[j]].length());
}
}
if(j==ins_rec_count-1){
- if(isQuotation){
+ if(cp.isQuotation){
colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(0,colData[fl_col_seq[j]].length()-1);
}
}
if (CmnUtils.isColString(colTypeName[tb_col_seq[j]])){
- if(isMask){
+ if(cp.isMask){
if(
- (isInclColsMask &&
- !isExclColsMask &&
- CmnUtils.isMatch(inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase())
+ (cp.isInclColsMask &&
+ !cp.isExclColsMask &&
+ CmnUtils.isMatch(cp.inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase())
) ||
- (isInclColsMask &&
- isExclColsMask &&
- CmnUtils.isMatch(inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) &&
- !CmnUtils.isMatch(exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
+ (cp.isInclColsMask &&
+ cp.isExclColsMask &&
+ CmnUtils.isMatch(cp.inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) &&
+ !CmnUtils.isMatch(cp.exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
) ||
- (!isInclColsMask &&
- isExclColsMask &&
- !CmnUtils.isMatch(exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
+ (!cp.isInclColsMask &&
+ cp.isExclColsMask &&
+ !CmnUtils.isMatch(cp.exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
)
){
StringBuffer sb = new StringBuffer();
for(int l=0;l<colData[fl_col_seq[j]].length();l++){
- if((maskPattern.toUpperCase().equals(MASK_PTN[MASK_PTN_ALT]) &&
+ if((cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALT]) &&
(l % 2) == 1) ||
- (maskPattern.toUpperCase().equals(MASK_PTN[MASK_PTN_EDGE]) &&
+ (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_EDGE]) &&
!(l == 0 || j == colData[fl_col_seq[j]].length() - 1) ||
- (maskPattern.toUpperCase().equals(MASK_PTN[MASK_PTN_ALL]))
+ (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALL]))
)
){
if(CmnUtils.isHankaku(colData[fl_col_seq[j]].charAt(l))){
- sb.append(singleByteMaskChar);
+ sb.append(cp.singleByteMaskChar);
} else {
- sb.append(doubleByteMaskChar);
+ sb.append(cp.doubleByteMaskChar);
}
} else {
sb.append(colData[fl_col_seq[j]].charAt(l));
}
}
if (!colData[fl_col_seq[j]].equals("")){
- if(isQuotation){
+ if(cp.isQuotation){
stmt_ins.setString(j+1,colData[fl_col_seq[j]].replaceAll("\"\"","\""));
} else {
stmt_ins.setString(j+1,colData[fl_col_seq[j]]);
}
}
fl_rec_count++;
- if (fl_rec_count % batchCount == 0){
+ if (fl_rec_count % cp.batchCount == 0){
if(!isLob)stmt_ins.executeBatch();
CmnUtils.debugPrint("insert record=" + fl_rec_count);
}
}
}
} else {
- CmnUtils.errorPrint("Folder Not Found(" + fldr + ")");
- throw new Exception("Folder Not Found(" + fldr + ")");
+ throw new Exception("Folder Not Found(" + folder + ")");
}
dao.disconnect();