OSDN Git Service

20170128
[rapideact/rapideact.git] / com / rapide_act / RapideUnloader.java
index b62790a..7530302 100644 (file)
@@ -30,121 +30,6 @@ import java.sql.Timestamp;
 public class RapideUnloader{
        
        private String database = null;
-       private String driver = null;
-       private String user = null;
-       private String pass = null;
-       private String url = null;
-       private String tkSql;
-       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 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 [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"};
-       private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
-       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 static final String DEFAULT_FOLDER              = "output";
-       private static final String DEFAULT_PROP_FILE   = "RapideLoader.properties";
-
-       private String nullMark                                 = "";
-       private boolean isOrder                                 = false;
-       private boolean isQuotation                     = true;
-       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 inclMaskCols                     = null;
-       private String exclMaskCols                     = 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");
-       
-       private String [] prop_val = new String[KEYS];
-       
-
-       private 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"
-       };
 
        public static void main(String args[]){
                try {
@@ -160,43 +45,14 @@ public class RapideUnloader{
                }
        }
 
-       RapideUnloader(String _database) throws Exception{
+       RapideUnloader(String _database) {
                super();
                database = _database;
 
        }
 
-       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]);
-                       }
-                       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;
-                       }
-               }               
-       }
 
-       private void unload() throws Exception{
+       private void unload() {
                Connection conn                                 = null;
                PreparedStatement stmt                  = null;
                ResultSet rst                                   = null;
@@ -204,10 +60,9 @@ public class RapideUnloader{
                String sql_insert                               = null;
                String order_columns                    = "";
                int orders                                              = 0;
-               int dbType                                              = DB_TYPE_UNKNOWN;
 
                PrintWriter pw                                  = null;
-               File fldr                                               = null;
+               File folder                                             = null;
                ArrayList<String>  alColName    = null;
                ArrayList<String>  alColTypeName = null;
                ArrayList<Integer> alIsNullable = null;
@@ -216,120 +71,29 @@ public class RapideUnloader{
                ArrayList<String>  alData               = null;
                int tb_count                                    = 0;
                int tb_col_count                                = 0;
+               CmnProperty cp = null;
+               DataAccessObjects dao = null;
 
-
-
-               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_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_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_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]);
-               if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]);
-               if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT];
-               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]))inclMaskCols = prop_val[D_INCLCOLMASK].toUpperCase();
-               if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclMaskCols = 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(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE];
-
-               if(user == null){
-                       throw new Exception("user is null");
-               } else if (pass == null){
-                       throw new Exception("password 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_TBLKEYSQL])){
-                               tkSql = prop_val[D_TBLKEYSQL];
-                       } else {
-                               tkSql = tkSqlArray[dbType];
-                       }
-               } else {
-                       throw new Exception("dbtype unknown");
-               }
-
-               DataAccessObjects dao = new DataAccessObjects(user, pass, url, driver);
-               dao.setPropVal(prop_val);
                try {
-                       conn = dao.connect();
+                       cp = new CmnProperty();
+                       cp.setProperty(database);
                        
-                       if(outFolder != null){
-                               fldr = new File(outFolder);
+                       if(cp.outFolder != null){
+                               folder = new File(cp.outFolder);
                        } else {
                                if(database != null){
-                                       fldr = new File(DEFAULT_FOLDER + "/" + database.toUpperCase() + "_" + CmnUtils.getYmdhm());
+                                       folder = new File(cp.DEFAULT_OUT_FOLDER + "/" + database.toUpperCase() + "_" + CmnUtils.getYmdhm());
                                } else {
-                                       fldr = new File(DEFAULT_FOLDER + "/" + DB_TYPE_NAME[dbType].toUpperCase() + "_" + CmnUtils.getYmdhm());
+                                       folder = new File(cp.DEFAULT_OUT_FOLDER + "/" + cp.DB_TYPE_NAME[cp.dbType].toUpperCase() + "_" + CmnUtils.getYmdhm());
                                }
-                               fldr.mkdir();
+                               folder.mkdir();
                        }
                        
-                       if(database!=null)CmnUtils.infoPrint("-->Database='" + database.toUpperCase() + "'");
-                       CmnUtils.infoPrint("-->Output='" + fldr + "'");
-                       if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))CmnUtils.infoPrint("-->Delimiter='" + prop_val[D_DELIMITER] + "'");
-                       if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))CmnUtils.infoPrint("-->LineSeparator='" + prop_val[D_LINESEP] + "'");
-                       if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))CmnUtils.infoPrint("-->FileEncoding='" + prop_val[D_FILENCODE] + "'");
-                       if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]))CmnUtils.infoPrint("-->Quotation=" + CmnUtils.getYesNo(isQuotation));
-                       if(!CmnUtils.isEmpty(prop_val[D_ORDER]))CmnUtils.infoPrint("-->Sort=" + CmnUtils.getYesNo(isOrder));
-                       if(isInclTables)CmnUtils.infoPrint("-->Include Tables='" + inclTables.toUpperCase() + "'");
-                       if(isExclTables)CmnUtils.infoPrint("-->Exclude Tables='" + exclTables.toUpperCase() + "'");
-                       if(isInclCols)CmnUtils.infoPrint("-->Include Columns='" + inclCols.toUpperCase() + "'");
-                       if(isExclCols)CmnUtils.infoPrint("-->Exclude Columns='" + exclCols.toUpperCase() + "'");
-                       if(isMask){
-                               CmnUtils.infoPrint("-->Masking=" + CmnUtils.getYesNo(isMask));
-                               CmnUtils.infoPrint("-->Masking Pattern=" + maskPattern.toUpperCase());
-                               if(isInclColsMask)CmnUtils.infoPrint("-->Masking Columns='" + inclMaskCols.toUpperCase() + "'");
-                               if(isExclColsMask)CmnUtils.infoPrint("-->Exclude Masking Columns='" + exclMaskCols.toUpperCase() + "'");
-                               CmnUtils.infoPrint("-->Single Byte Mask Char='" + singleByteMaskChar + "'");
-                               CmnUtils.infoPrint("-->Double Byte Mask Char='" + doubleByteMaskChar + "'");
-                       }
-                       CmnUtils.infoPrint("Start DataUnload ---------------------------------------------");
-
-                       dao.select(tkSql);
+                       CmnUtils.infoPrint("-->\8fo\97Í\90æ\83t\83H\83\8b\83_='" + folder + "'");
+                       CmnUtils.infoPrint("\83f\81[\83^\83A\83\93\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82µ\82½\81B");
+                       dao = new DataAccessObjects(cp);
+                       conn = dao.connect();
+                       dao.select(cp.tkSql);
                        alData = dao.getArrayList();
                        tb_count = dao.getColumnCount();
                        orders = 0;
@@ -338,22 +102,22 @@ public class RapideUnloader{
                        for(int i=0;i<alData.size();i++){
                                if ((i+1) % tb_count == 1){
                                        if ((i + 2 <alData.size()) && (!alData.get(i).equals(alData.get(i+2))) || (i + 2 == alData.size())) {
-                                               if(isInclTables && !CmnUtils.isMatch(inclTablesArray,alData.get(i).toUpperCase())){
-                                                       CmnUtils.debugPrint("inclTables=" + inclTables);
-                                                       CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(inclTablesArray,alData.get(i).toUpperCase()));
+                                               if(cp.isInclTables && !CmnUtils.isMatch(cp.inclTablesArray,alData.get(i).toUpperCase())){
+                                                       CmnUtils.debugPrint("cp.inclTables=" + cp.inclTables);
+                                                       CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(cp.inclTablesArray,alData.get(i).toUpperCase()));
                                                        orders = 0;
                                                        order_columns = "";
                                                        continue;
                                                }
-                                               if(isExclTables && CmnUtils.isMatch(exclTablesArray,alData.get(i).toUpperCase())){
-                                                       CmnUtils.debugPrint("exclTables=" + exclTables);
-                                                       CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(exclTablesArray,alData.get(i).toUpperCase()));
+                                               if(cp.isExclTables && CmnUtils.isMatch(cp.exclTablesArray,alData.get(i).toUpperCase())){
+                                                       CmnUtils.debugPrint("cp.exclTables=" + cp.exclTables);
+                                                       CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(cp.exclTablesArray,alData.get(i).toUpperCase()));
                                                        orders = 0;
                                                        order_columns = "";
                                                        continue;
                                                }
                                                if (!alData.get(i+1).equals("")){
-                                                       if(isOrder){
+                                                       if(cp.isOrder){
                                                                if (orders == 0){
                                                                        if (!alData.get(i+1).equals(""))order_columns = alData.get(i+1);
                                                                } else {
@@ -362,7 +126,7 @@ public class RapideUnloader{
                                                                orders++;
                                                        }
                                                }                                                       
-                                               if(isOrder){
+                                               if(cp.isOrder){
                                                        if(!order_columns.equals("")){
                                                                sql_unload = "select * from " + alData.get(i) + " order by " + order_columns;
                                                        } else {
@@ -382,20 +146,20 @@ public class RapideUnloader{
                                                tb_col_count = dao.getColumnCount();
                                                for(int j=0;j<alColName.size();j++){
                                                        if(CmnUtils.isColString(alColTypeName.get(j))){
-                                                               if(isMask){
+                                                               if(cp.isMask){
                                                                        if(
-                                                                               (isInclColsMask && 
-                                                                                !isExclColsMask &&
-                                                                                CmnUtils.isMatch(inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                               (cp.isInclColsMask && 
+                                                                                !cp.isExclColsMask &&
+                                                                                CmnUtils.isMatch(cp.inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
                                                                                ) ||
-                                                                               (isInclColsMask && 
-                                                                                isExclColsMask &&
-                                                                                CmnUtils.isMatch(inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) &&
-                                                                                !CmnUtils.isMatch(exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                               (cp.isInclColsMask && 
+                                                                                cp.isExclColsMask &&
+                                                                                CmnUtils.isMatch(cp.inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) &&
+                                                                                !CmnUtils.isMatch(cp.exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
                                                                                ) ||
-                                                                               (!isInclColsMask && 
-                                                                                isExclColsMask &&
-                                                                                !CmnUtils.isMatch(exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                               (!cp.isInclColsMask && 
+                                                                                cp.isExclColsMask &&
+                                                                                !CmnUtils.isMatch(cp.exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
                                                                                ) 
                                                                        ){
                                                                                CmnUtils.debugPrint("Mask Column=" + alColName.get(j).toUpperCase());
@@ -409,20 +173,20 @@ public class RapideUnloader{
                                                        } else {
                                                                alColMask.add(false);
                                                        }
-                                                       if(isInclCols || isExclCols){
+                                                       if(cp.isInclCols || cp.isExclCols){
                                                                if(
-                                                                       (isInclCols && 
-                                                                        !isExclCols &&
-                                                                        CmnUtils.isMatch(inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase())
+                                                                       (cp.isInclCols && 
+                                                                        !cp.isExclCols &&
+                                                                        CmnUtils.isMatch(cp.inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase())
                                                                        ) ||
-                                                                       (isInclCols && 
-                                                                        isExclCols &&
-                                                                        CmnUtils.isMatch(inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase()) &&
-                                                                        !CmnUtils.isMatch(exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                       (cp.isInclCols && 
+                                                                        cp.isExclCols &&
+                                                                        CmnUtils.isMatch(cp.inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase()) &&
+                                                                        !CmnUtils.isMatch(cp.exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
                                                                        ) ||
-                                                                       (!isInclCols && 
-                                                                        isExclCols &&
-                                                                        !CmnUtils.isMatch(exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                       (!cp.isInclCols && 
+                                                                        cp.isExclCols &&
+                                                                        !CmnUtils.isMatch(cp.exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
                                                                        )
                                                                ){
                                                                        CmnUtils.debugPrint("column=" + alColName.get(j).toUpperCase());
@@ -455,12 +219,12 @@ public class RapideUnloader{
                                                dao.setArrayColumnMaskList(alColMask);
                                                
                                                if (lastCol >= 0){
-                                                       pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fldr + "/" + alData.get(i) + ".csv"), fileEncoding)));
+                                                       pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(folder + "/" + alData.get(i) + ".csv"), cp.fileEncoding)));
                                                        CmnUtils.infoPrinting(String.format("%1$-30s",alData.get(i)));
 
                                                        for(int j=0;j<alColName.size();j++){
                                                                if(j==firstCol){
-                                                                       if(isQuotation){
+                                                                       if(cp.isQuotation){
                                                                                pw.print("\"" + alColName.get(j));
                                                                        } else {
                                                                                pw.print(alColName.get(j));
@@ -469,24 +233,24 @@ public class RapideUnloader{
                                                                        if(colIncl[j])pw.print(alColName.get(j));
                                                                }
                                                                if (firstCol == lastCol){
-                                                                       if(isQuotation){
-                                                                               pw.print("\"" + lineSeparator);
+                                                                       if(cp.isQuotation){
+                                                                               pw.print("\"" + cp.lineSeparator);
                                                                        } else {
-                                                                               pw.print("" + lineSeparator);
+                                                                               pw.print("" + cp.lineSeparator);
                                                                        }
                                                                } else {
                                                                        if (j==lastCol){
-                                                                               if(isQuotation){
-                                                                                       pw.print("\"" + lineSeparator);
+                                                                               if(cp.isQuotation){
+                                                                                       pw.print("\"" + cp.lineSeparator);
                                                                                } else {
-                                                                                       pw.print("" + lineSeparator);
+                                                                                       pw.print("" + cp.lineSeparator);
                                                                                }
                                                                        } else {
                                                                                if(colIncl[j]){
-                                                                                       if(isQuotation){
-                                                                                               pw.print("\"" + delimiter + "\"");
+                                                                                       if(cp.isQuotation){
+                                                                                               pw.print("\"" + cp.delimiter + "\"");
                                                                                        } else {
-                                                                                               pw.print(delimiter);
+                                                                                               pw.print(cp.delimiter);
                                                                                        }
                                                                                }
                                                                        }
@@ -496,13 +260,13 @@ public class RapideUnloader{
                                                        dao.closeRecordSet();
                                                        pw.close();
                                                        pw = null;
-                                                       System.out.println(String.format("%1$10d",dao.getRecCount()) + " rows exported");
+                                                       System.out.println(String.format("%1$10d",dao.getRecCount()) + " \8d\83A\83\93\83\8d\81[\83h\82³\82ê\82Ü\82µ\82½\81B");
                                                }
                                                orders = 0;
                                                order_columns = "";
                                        } else {
                                                if (!alData.get(i+1).equals("")){
-                                                       if(isOrder){
+                                                       if(cp.isOrder){
                                                                if (orders == 0){
                                                                        if (!alData.get(i+1).equals(""))order_columns = alData.get(i+1);
                                                                } else {
@@ -517,17 +281,27 @@ public class RapideUnloader{
                                }
                        }
 
-                       dao.disconnect();
+                       CmnUtils.infoPrint("\83f\81[\83^\83A\83\93\83\8d\81[\83h\82ð\8fI\97¹\82µ\82Ü\82µ\82½\81B");
 
                } catch (Exception e) {                 
-                       throw e;
+                       try{
+                               CmnUtils.errorPrint(e.toString());
+                               e.printStackTrace();
+                               dao.rollback();
+                       } catch (Exception ee) {}
                } finally{
-                       if(pw!=null){
-                               pw.close();
-                               pw=null;
-                       }
+                       try{
+                               dao.disconnect();
+                               if(stmt != null){
+                                       stmt.close();
+                                       stmt=null;
+                               }
+                               if(pw!=null){
+                                       pw.close();
+                                       pw=null;
+                               }
+                       } catch (Exception e) {}
                }
-               CmnUtils.infoPrint("End DataUnload -----------------------------------------------");
        }