OSDN Git Service

20170128
[rapideact/rapideact.git] / com / rapide_act / RapideLoader.java
index cfa5480..ef9b889 100644 (file)
@@ -50,12 +50,12 @@ public class RapideLoader{
        }
 
 
-       RapideLoader(String _database) throws Exception{
+       RapideLoader(String _database) {
                super();
                database = _database;
        }
 
-       private void load() throws Exception{
+       private void load(){
                Connection conn                                 = null;
                PreparedStatement stmt                  = null;
                PreparedStatement stmt_ins              = null;
@@ -85,14 +85,12 @@ public class RapideLoader{
                int fl_col_count                                = 0;
                boolean isLob                                   = false;
                boolean isContinue                              = false;
+               CmnProperty cp = null;
+               DataAccessObjects dao = null;
 
-               CmnProperty cp = new CmnProperty();
-               cp.setProperty(database);
-               
-               DataAccessObjects dao = new DataAccessObjects(cp.user, cp.pass, cp.url, cp.driver);
                try {
-                       conn = dao.connect();
-                       conn.setAutoCommit(false);
+                       cp = new CmnProperty();
+                       cp.setProperty(database);
 
                        if(cp.inFolder != null){
                                folder = new File(cp.inFolder);
@@ -103,9 +101,11 @@ public class RapideLoader{
                                        folder = new File(cp.DEFAULT_IN_FOLDER + "/" + cp.DB_TYPE_NAME[cp.dbType].toUpperCase());
                                }
                        }
-                       CmnUtils.infoPrint("-->\93ü\97Í\8c³='" + folder + "'");
+                       CmnUtils.infoPrint("-->\93ü\97Í\8c³\83t\83H\83\8b\83_='" + folder + "'");
                        CmnUtils.infoPrint("\83f\81[\83^\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82µ\82½\81B");
-
+                       dao = new DataAccessObjects(cp);
+                       conn = dao.connect();
+                       conn.setAutoCommit(false);
                        dao.select(cp.tSql);
                        alData = dao.getArrayList();
                        tb_count = dao.getColumnCount();
@@ -202,7 +202,6 @@ public class RapideLoader{
                                                                        }
 
                                                                        colIncl = (Boolean[])alColIncl.toArray(new Boolean[0]);
-
                                                                        sql_insert = "INSERT INTO " + tbName + "(";
                                                                        for(int j=0;j<colData.length;j++){
                                                                                for(int l=0;l<tb_col_count;l++){
@@ -237,7 +236,7 @@ public class RapideLoader{
                                                                                CmnUtils.infoPrinting(String.format("%1$-30s",tbName));
                                                                        } else {
                                                                                dao.rollback();
-                                                                               CmnUtils.debugPrint("column count is zero");
+                                                                               CmnUtils.debugPrint("\8ew\92è\82µ\82½\8bæ\90Ø\82è\95\8e\9a\82Å\82Ì\83J\83\89\83\80\90\94\82ª0\82Å\82·\81B");
                                                                                if(br != null){
                                                                                        br.close();
                                                                                        br=null;
@@ -257,7 +256,7 @@ public class RapideLoader{
                                                                        if(colData.length == fl_col_count){
                                                                                if(!strMltLine.equals("")){
                                                                                        dao.rollback();
-                                                                                       System.out.println(String.format("%1$10d",tb_rec_count) + " ERROR:column count is unmatch");
+                                                                                       CmnUtils.errorPrint("\8aY\93\96\83\8c\83R\81[\83h\82Ì\83J\83\89\83\80\90\94\82ª\83A\83\93\83}\83b\83`\82Å\82·\81B[" + tb_rec_count + "]");
                                                                                        CmnUtils.debugPrint("************Record End");
                                                                                        if(br != null){
                                                                                                br.close();
@@ -286,7 +285,7 @@ public class RapideLoader{
                                                                                                isContinue = false;
                                                                                        } else if(colData.length >fl_col_count){
                                                                                                dao.rollback();
-                                                                                               CmnUtils.errorPrint(String.format("%1$10d",tb_rec_count) + "column count is unmatch");
+                                                                                               CmnUtils.errorPrint("\8aY\93\96\83\8c\83R\81[\83h\82Ì\83J\83\89\83\80\90\94\82ª\83A\83\93\83}\83b\83`\82Å\82·\81B[" + tb_rec_count + "]");
                                                                                                CmnUtils.debugPrint("************Record End");
                                                                                                if(br != null){
                                                                                                        br.close();
@@ -432,7 +431,7 @@ public class RapideLoader{
                                                                                                        stmt_ins.setClob(j+1,null,0);
                                                                                                }
                                                                                        } else {
-                                                                                               CmnUtils.errorPrint("unmatch column type=" + colTypeName[tb_col_seq[j]]);
+                                                                                               CmnUtils.errorPrint("\83J\83\89\83\80\82Ì\83f\81[\83^\8c^\82ª\91Î\8fÛ\8aO\82Å\82·\81B[" + colTypeName[tb_col_seq[j]] + "]");
                                                                                                break TABLE_LOOP;
                                                                                        }
                                                                                }
@@ -453,7 +452,7 @@ public class RapideLoader{
                                                        }
                                                        if(!isLob)stmt_ins.executeBatch();
                                                        dao.commit();
-                                                       System.out.println(String.format("%1$10d",tb_rec_count) + " rows imported");
+                                                       System.out.println(String.format("%1$10d",tb_rec_count) + " \8d\83\8d\81[\83h\82³\82ê\82Ü\82µ\82½\81B");
                                                        CmnUtils.debugPrint("************Record End");
                                                        if(br != null){
                                                                br.close();
@@ -468,31 +467,33 @@ public class RapideLoader{
                                        }
                                }
                        } else {
-                               throw new Exception("Folder Not Found(" + folder + ")");
+                               CmnUtils.errorPrint("\93ü\97Í\8c³\83t\83H\83\8b\83_\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81B[" + folder + "]");
                        }
 
-                       dao.disconnect();
+                       CmnUtils.infoPrint("\83f\81[\83^\83\8d\81[\83h\82ð\8fI\97¹\82µ\82Ü\82µ\82½\81B");
 
                } catch (Exception e) {
-                       dao.rollback();
-                       throw e;
+                       try{
+                               CmnUtils.errorPrint(e.toString());
+                               e.printStackTrace();
+                               dao.rollback();
+                       } catch (Exception ee) {}
                } finally{
-                       if(stmt != null){
-                               stmt.close();
-                               stmt=null;
-                       }
-                       if(stmt_ins != null){
-                               stmt_ins.close();
-                               stmt_ins=null;
-                       }
-                       if(br!=null){
-                               br.close();
-                               br=null;
-                       }
+                       try{
+                               dao.disconnect();
+                               if(stmt != null){
+                                       stmt.close();
+                                       stmt=null;
+                               }
+                               if(stmt_ins != null){
+                                       stmt_ins.close();
+                                       stmt_ins=null;
+                               }
+                               if(br!=null){
+                                       br.close();
+                                       br=null;
+                               }
+                       } catch (Exception e) {}
                }
-               CmnUtils.infoPrint("\83f\81[\83^\83\8d\81[\83h\82ð\8fI\97¹\82µ\82Ü\82µ\82½\81B");
        }
-       
-
 }
-