OSDN Git Service

5f013ea5a50f9a878147560e57a62000ab2f6400
[rapideact/rapideact.git] / com / rapide_act / RapideLoader.java
1 package com.rapide_act;
2
3 import java.io.BufferedInputStream;
4 import java.io.BufferedReader;
5 import java.io.BufferedWriter;
6 import java.io.FileInputStream;
7 import java.io.InputStream;
8 import java.io.InputStreamReader;
9 import java.io.IOException;
10 import java.io.File;
11 import java.io.FileReader;
12 import java.io.FileWriter;
13 import java.io.PrintWriter;
14 import java.io.PrintWriter;
15 import java.util.Date;
16 import java.util.ArrayList;
17 import java.util.Iterator;
18 import java.util.Properties;
19 import java.sql.Blob;
20 import java.sql.Clob;
21 import java.sql.Connection;
22 import java.sql.DriverManager;
23 import java.sql.PreparedStatement;
24 import java.sql.ResultSet;
25 import java.sql.ResultSetMetaData;
26 import java.sql.SQLException;
27 import java.sql.Timestamp;
28 import java.math.BigDecimal;
29 import java.math.BigInteger;
30
31 public class RapideLoader{
32         private String database = null;
33
34         public static void main(String args[]){
35                 try {
36                         if (args.length > 0){
37                                 RapideLoader rapideLoader = new RapideLoader(args[0]);
38                                 rapideLoader.load();
39                         } else {
40                                 RapideLoader rapideLoader = new RapideLoader(null);
41                                 rapideLoader.load();
42                         }
43                 } catch (Exception e) {
44                         try{
45                                 CmnUtils.errorPrint(e.toString());
46                                 e.printStackTrace();
47                         } catch (Exception ee){
48                                 ee.printStackTrace();
49                         }
50                 }
51         }
52
53
54         RapideLoader(String _database) {
55                 super();
56                 database = _database;
57         }
58
59         private void load(){
60                 Connection conn                                 = null;
61                 PreparedStatement stmt                  = null;
62                 PreparedStatement stmt_ins              = null;
63                 BufferedReader br                               = null;
64                 String sql_load                                 = null;
65                 String sql_insert                               = null;
66                 String strLine                                  = null;
67                 String strMltLine                               = null;
68                 String tbName                                   = null;
69                 String [] flName                                = null;
70                 String [] colData                               = null;
71                 String [] colName                               = null;
72                 String [] colTypeName                   = null;
73                 Integer [] isNullable                   = null;
74                 Boolean [] colIncl                              = null;
75
76                 File folder                                             = null;
77                 ArrayList<String> alData                = null;
78                 ArrayList<String> alColName     = null;
79                 ArrayList<String> alColTypeName = null;
80                 ArrayList<Integer> alIsNullable = null;
81                 ArrayList<Boolean> alColMask    = null;
82                 ArrayList<Boolean> alColIncl    = null;
83
84                 int tb_count                                    = 0;
85                 int tb_col_count                                = 0;
86                 int fl_col_count                                = 0;
87                 boolean isLob                                   = false;
88                 boolean isContinue                              = false;
89                 CmnProperty cp = null;
90                 DataAccessObjects dao = null;
91
92                 try {
93                         cp = new CmnProperty();
94                         cp.setProperty(database);
95
96                         if(cp.inFolder != null){
97                                 folder = new File(cp.inFolder);
98                         } else {
99                                 if (database != null){
100                                         folder = new File(cp.DEFAULT_IN_FOLDER + "/" + database.toUpperCase());
101                                 } else {
102                                         folder = new File(cp.DEFAULT_IN_FOLDER + "/" + cp.DB_TYPE_NAME[cp.dbType].toUpperCase());
103                                 }
104                         }
105                         CmnUtils.infoPrint("-->\93ü\97Í\8c³\83t\83H\83\8b\83_='" + folder + "'");
106                         CmnUtils.infoPrint("\83f\81[\83^\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82µ\82½\81B");
107                         dao = new DataAccessObjects(cp);
108                         conn = dao.connect();
109                         conn.setAutoCommit(false);
110                         dao.select(cp.tSql);
111                         alData = dao.getArrayList();
112                         tb_count = dao.getColumnCount();
113                         int tb_rec_count = 0;
114                         int fl_rec_count = 0;
115                         int ins_rec_count = 0;
116                         int tb_fl_match_count = 0;
117                         File [] inFiles = folder.listFiles();
118                         if(inFiles != null) {
119                                 for(int k=0;k<inFiles.length;k++){
120                                         flName = CmnUtils.splitDot(inFiles[k].getName());
121                                         tbName = flName[0].toUpperCase();
122                                         StringBuffer sbColumnName = null;
123                                         TABLE_LOOP:
124                                         for(int i=0;i<alData.size();i++){
125                                                 if(tbName.toUpperCase().equals(alData.get(i).toUpperCase())){
126                                                         if(cp.isInclTables && !CmnUtils.isMatch(cp.inclTablesArray,tbName.toUpperCase())){
127                                                                 CmnUtils.debugPrint("cp.inclTables=" + cp.inclTables);
128                                                                 CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(cp.inclTablesArray,tbName.toUpperCase()));
129                                                                 continue;
130                                                         }
131                                                         if(cp.isExclTables && CmnUtils.isMatch(cp.exclTablesArray,tbName.toUpperCase())){
132                                                                 CmnUtils.debugPrint("cp.exclTables=" + cp.exclTables);
133                                                                 CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(cp.exclTablesArray,tbName.toUpperCase()));
134                                                                 continue;
135                                                         }
136                                                         br = new BufferedReader(new InputStreamReader(new FileInputStream(folder + "/" + alData.get(i) + "." + flName[1]), cp.fileEncoding));
137                                                         sql_load = "select * from " + alData.get(i);
138                                                         stmt = dao.prepareSql(sql_load);
139                                                         dao.executeSql(stmt);
140                                                         alColName = dao.getArrayColumnNameList();
141                                                         alColTypeName = dao.getArrayColumnTypeNameList();
142                                                         alIsNullable = dao.getArrayIsNullableList();
143                                                         alColMask = new ArrayList<Boolean>();
144                                                         alColIncl = new ArrayList<Boolean>();
145                                                         colName = (String[])alColName.toArray(new String[0]);
146                                                         colTypeName = (String[])alColTypeName.toArray(new String[0]);
147                                                         isNullable = (Integer[])alIsNullable.toArray(new Integer[0]);
148                                                         tb_col_count = dao.getColumnCount();
149                                                         int [] tb_col_seq = new int[tb_col_count];
150                                                         int [] fl_col_seq = null;
151                                                         dao.closeRecordSet();
152                                                         tb_rec_count = 0;
153                                                         fl_rec_count = 0;
154                                                         ins_rec_count = 0;
155                                                         fl_col_count = 0;
156                                                         tb_fl_match_count = 0;
157                                                         strMltLine = "";
158                                                         isContinue = false;
159                                                         isLob = false;
160                                                         for(int j=0;j<colTypeName.length;j++)if(CmnUtils.isLob(colTypeName[j]))isLob = true;
161                                                         CmnUtils.debugPrint("LOB="+isLob);
162                                                         while((strLine=br.readLine()) != null){
163                                                                 if (fl_rec_count == 0){
164                                                                         if(cp.isQuotation){
165                                                                                 colData = CmnUtils.split(strLine,"\"" + cp.delimiter + "\"");
166                                                                         } else {
167                                                                                 colData = CmnUtils.split(strLine,cp.delimiter);
168                                                                         }
169                                                                         fl_col_count = colData.length;
170                                                                         fl_col_seq = new int[colData.length];
171                                                                         CmnUtils.debugPrint("TableName=" + tbName);
172                                                                         
173                                                                         for(int j=0;j<colData.length;j++){
174                                                                                 for(int l=0;l<tb_col_count;l++){
175                                                                                         if(colName[l].equals(colData[j].replaceAll("\"",""))){
176                                                                                                 if(cp.isInclCols || cp.isExclCols){
177                                                                                                         if(
178                                                                                                                 (cp.isInclCols && 
179                                                                                                                  !cp.isExclCols &&
180                                                                                                                  CmnUtils.isMatch(cp.inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
181                                                                                                                 ) ||
182                                                                                                                 (cp.isInclCols && 
183                                                                                                                  cp.isExclCols &&
184                                                                                                                  CmnUtils.isMatch(cp.inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase()) &&
185                                                                                                                  !CmnUtils.isMatch(cp.exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
186                                                                                                                 ) ||
187                                                                                                                 (!cp.isInclCols && 
188                                                                                                                  cp.isExclCols &&
189                                                                                                                  !CmnUtils.isMatch(cp.exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
190                                                                                                                 )
191                                                                                                         ){
192                                                                                                                 CmnUtils.debugPrint("\91Î\8fÛ\83J\83\89\83\80=" + colName[l].toUpperCase());
193                                                                                                                 alColIncl.add(true);
194                                                                                                         } else {
195                                                                                                                 alColIncl.add(false);
196                                                                                                         }
197                                                                                                 } else {
198                                                                                                         alColIncl.add(true);
199                                                                                                 }
200                                                                                                 break;
201                                                                                         }
202                                                                                 }
203                                                                         }
204
205                                                                         colIncl = (Boolean[])alColIncl.toArray(new Boolean[0]);
206                                                                         sql_insert = "INSERT INTO " + tbName + "(";
207                                                                         for(int j=0;j<colData.length;j++){
208                                                                                 for(int l=0;l<tb_col_count;l++){
209                                                                                         if(colName[l].equals(colData[j].replaceAll("\"",""))){
210                                                                                                 if (colIncl[tb_fl_match_count]) {
211                                                                                                         if (ins_rec_count == 0){
212                                                                                                                 sql_insert += colName[l];
213                                                                                                         } else {
214                                                                                                                 sql_insert += "," + colName[l];
215                                                                                                         }
216                                                                                                         tb_col_seq[ins_rec_count]=l;
217                                                                                                         fl_col_seq[ins_rec_count]=j;
218                                                                                                         ins_rec_count++;
219                                                                                                 }
220                                                                                                 tb_fl_match_count++;
221                                                                                                 break;
222                                                                                         }
223                                                                                 }
224                                                                         }
225                                                                         if (ins_rec_count > 0){
226                                                                                 sql_insert += ") VALUES(";
227                                                                                 for(int j=0;j<ins_rec_count;j++){
228                                                                                         if(j==0){
229                                                                                                 sql_insert += "?";
230                                                                                         } else {
231                                                                                                 sql_insert += ", ?";
232                                                                                         }
233                                                                                 }
234                                                                                 sql_insert += ")";
235                                                                                 stmt_ins = dao.prepareSql(sql_insert);
236                                                                                 CmnUtils.debugPrint("************Record Start");
237                                                                                 CmnUtils.infoPrinting(String.format("%1$-30s",tbName));
238                                                                         } else {
239                                                                                 dao.rollback();
240                                                                                 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");
241                                                                                 if(br != null){
242                                                                                         br.close();
243                                                                                         br=null;
244                                                                                 }
245                                                                                 if(stmt_ins != null){
246                                                                                         stmt_ins.close();
247                                                                                         stmt_ins=null;
248                                                                                 }
249                                                                                 break TABLE_LOOP;
250                                                                         }
251                                                                 } else {
252                                                                         if(cp.isQuotation){
253                                                                                 colData = CmnUtils.split(strLine,"\"" + cp.delimiter + "\"");
254                                                                         } else {
255                                                                                 colData = CmnUtils.split(strLine,cp.delimiter);
256                                                                         }
257                                                                         if(colData.length == fl_col_count){
258                                                                                 if(!strMltLine.equals("")){
259                                                                                         dao.rollback();
260                                                                                         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 + "]");
261                                                                                         CmnUtils.debugPrint("************Record End");
262                                                                                         if(br != null){
263                                                                                                 br.close();
264                                                                                                 br=null;
265                                                                                         }
266                                                                                         if(stmt_ins != null){
267                                                                                                 stmt_ins.close();
268                                                                                                 stmt_ins=null;
269                                                                                         }
270                                                                                         break TABLE_LOOP;
271                                                                                 } else {
272                                                                                         isContinue = false;
273                                                                                 }
274                                                                         } else {
275                                                                                 if (strMltLine.equals("")){
276                                                                                         strMltLine += strLine;
277                                                                                         isContinue = true;
278                                                                                 } else {
279                                                                                         strMltLine += cp.inColLineSeparator + strLine;
280                                                                                         if(cp.isQuotation){
281                                                                                                 colData = CmnUtils.split(strMltLine,"\"" + cp.delimiter + "\"");
282                                                                                         } else {
283                                                                                                 colData = CmnUtils.split(strMltLine,cp.delimiter);
284                                                                                         }
285                                                                                         if(colData.length == fl_col_count){
286                                                                                                 isContinue = false;
287                                                                                         } else if(colData.length >fl_col_count){
288                                                                                                 dao.rollback();
289                                                                                                 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 + "]");
290                                                                                                 CmnUtils.debugPrint("************Record End");
291                                                                                                 if(br != null){
292                                                                                                         br.close();
293                                                                                                         br=null;
294                                                                                                 }
295                                                                                                 if(stmt_ins != null){
296                                                                                                         stmt_ins.close();
297                                                                                                         stmt_ins=null;
298                                                                                                 }
299                                                                                                 break TABLE_LOOP;
300                                                                                         } else {
301                                                                                                 isContinue = true;
302                                                                                         }
303                                                                                 }
304                                                                         }
305                                                                         if(isContinue == false){
306                                                                                 for(int j=0;j<ins_rec_count;j++){
307                                                                                         if(j==0){
308                                                                                                 if(cp.isQuotation){
309                                                                                                         if(colData[fl_col_seq[j]].length()>1){
310                                                                                                                 colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(1,colData[fl_col_seq[j]].length());
311                                                                                                         } else {
312                                                                                                                 colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(1,colData[fl_col_seq[j]].length()).replaceAll("\"","");
313                                                                                                         }
314                                                                                                 }
315                                                                                         }
316                                                                                         if(j==ins_rec_count-1){
317                                                                                                 if(cp.isQuotation){
318                                                                                                         if(colData[fl_col_seq[j]].length()>1){
319                                                                                                                 colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(0,colData[fl_col_seq[j]].length()-1);
320                                                                                                         } else {
321                                                                                                                 colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(0,colData[fl_col_seq[j]].length()).replaceAll("\"","");
322                                                                                                         }
323                                                                                                 }
324                                                                                         }
325                                                                                         
326                                                                                         CmnUtils.deepPrint("[" + fl_rec_count + "]" + "[" + j + "]" + colName[tb_col_seq[j]].toUpperCase() + "." + colTypeName[tb_col_seq[j]] + "='" + colData[fl_col_seq[j]] + "'");
327                                                                                         if (CmnUtils.isColString(colTypeName[tb_col_seq[j]])){
328                                                                                                 if(cp.isMask){
329                                                                                                         if(
330                                                                                                                 (cp.isInclColsMask &&
331                                                                                                                  !cp.isExclColsMask && 
332                                                                                                                  CmnUtils.isMatch(cp.inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase())
333                                                                                                                 ) ||
334                                                                                                                 (cp.isInclColsMask &&
335                                                                                                                  cp.isExclColsMask && 
336                                                                                                                  CmnUtils.isMatch(cp.inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) &&
337                                                                                                                  !CmnUtils.isMatch(cp.exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
338                                                                                                                 ) ||
339                                                                                                                 (!cp.isInclColsMask &&
340                                                                                                                  cp.isExclColsMask && 
341                                                                                                                  !CmnUtils.isMatch(cp.exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
342                                                                                                                 )
343                                                                                                         ){
344                                                                                                                 StringBuffer sb = new StringBuffer();
345                                                                                                                 for(int l=0;l<colData[fl_col_seq[j]].length();l++){
346                                                                                                                         if((cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALT]) && 
347                                                                                                                                         (l % 2) == 1) || 
348                                                                                                                            (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_EDGE]) && 
349                                                                                                                                         !(l == 0 || j == colData[fl_col_seq[j]].length() - 1) ||
350                                                                                                                            (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALL]))
351                                                                                                                            )
352                                                                                                                         ){
353                                                                                                                                 if(CmnUtils.isHankaku(colData[fl_col_seq[j]].charAt(l))){
354                                                                                                                                         sb.append(cp.singleByteMaskChar);
355                                                                                                                                 } else {
356                                                                                                                                         sb.append(cp.doubleByteMaskChar);
357                                                                                                                                 }
358                                                                                                                         } else {
359                                                                                                                                 sb.append(colData[fl_col_seq[j]].charAt(l));
360                                                                                                                         }
361                                                                                                                 }
362                                                                                                                 colData[fl_col_seq[j]] = sb.toString();
363                                                                                                         }
364                                                                                                 }
365                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
366                                                                                                         if(cp.isQuotation){
367                                                                                                                 stmt_ins.setString(j+1,colData[fl_col_seq[j]].replaceAll("\"\"","\""));
368                                                                                                         } else {
369                                                                                                                 stmt_ins.setString(j+1,colData[fl_col_seq[j]]);
370                                                                                                         }
371                                                                                                 } else {
372                                                                                                         if(isNullable[j] == 0){
373                                                                                                                 stmt_ins.setString(j+1," ");
374                                                                                                         } else {
375                                                                                                                 stmt_ins.setString(j+1,null);
376                                                                                                         }
377                                                                                                 }
378                                                                                         } else if (CmnUtils.isColDate(colTypeName[tb_col_seq[j]])){
379                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
380                                                                                                         stmt_ins.setDate(j+1,java.sql.Date.valueOf(colData[fl_col_seq[j]]));
381                                                                                                 } else {
382                                                                                                         stmt_ins.setDate(j+1,null);
383                                                                                                 }
384                                                                                         } else if (CmnUtils.isColYear(colTypeName[tb_col_seq[j]])){
385                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
386                                                                                                         stmt_ins.setString(j+1,colData[fl_col_seq[j]]);
387                                                                                                 } else {
388                                                                                                         stmt_ins.setDate(j+1,null);
389                                                                                                 }
390                                                                                         } else if (CmnUtils.isColTime(colTypeName[tb_col_seq[j]])){
391                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
392                                                                                                         stmt_ins.setTime(j+1,java.sql.Time.valueOf(colData[fl_col_seq[j]]));
393                                                                                                 } else {
394                                                                                                         stmt_ins.setTime(j+1,null);
395                                                                                                 }
396                                                                                         } else if (CmnUtils.isColTimestamp(colTypeName[tb_col_seq[j]])){
397                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
398                                                                                                         stmt_ins.setTimestamp(j+1,java.sql.Timestamp.valueOf(colData[fl_col_seq[j]]));
399                                                                                                         //CmnUtils.debugPrint("Timestamp=" + colData[fl_col_seq[j]]);
400                                                                                                 } else {
401                                                                                                         stmt_ins.setTimestamp(j+1,null);
402                                                                                                 }
403                                                                                         } else if (CmnUtils.isColBigDecimal(colTypeName[tb_col_seq[j]])){
404                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
405                                                                                                         stmt_ins.setBigDecimal(j+1,new BigDecimal(colData[fl_col_seq[j]]));
406                                                                                                 } else {
407                                                                                                         stmt_ins.setNull(j+1,java.sql.Types.DECIMAL);
408                                                                                                 }
409                                                                                         } else if (CmnUtils.isColShort(colTypeName[tb_col_seq[j]])){
410                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
411                                                                                                         stmt_ins.setShort(j+1,Short.parseShort(colData[fl_col_seq[j]]));
412                                                                                                 } else {
413                                                                                                         stmt_ins.setNull(j+1,java.sql.Types.SMALLINT);
414                                                                                                 }
415                                                                                         } else if (CmnUtils.isColInt(colTypeName[tb_col_seq[j]])){
416                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
417                                                                                                         stmt_ins.setInt(j+1,Integer.parseInt(colData[fl_col_seq[j]]));
418                                                                                                 } else {
419                                                                                                         stmt_ins.setNull(j+1,java.sql.Types.INTEGER);
420                                                                                                 }
421                                                                                         } else if (CmnUtils.isColLong(colTypeName[tb_col_seq[j]])){
422                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
423                                                                                                         stmt_ins.setLong(j+1,Long.parseLong(colData[fl_col_seq[j]]));
424                                                                                                 } else {
425                                                                                                         stmt_ins.setNull(j+1,java.sql.Types.BIGINT);
426                                                                                                 }
427                                                                                         } else if (CmnUtils.isColFloat(colTypeName[tb_col_seq[j]])){
428                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
429                                                                                                         stmt_ins.setFloat(j+1,Float.parseFloat(colData[fl_col_seq[j]]));
430                                                                                                 } else {
431                                                                                                         stmt_ins.setNull(j+1,java.sql.Types.REAL);
432                                                                                                 }
433                                                                                         } else if (CmnUtils.isColDouble(colTypeName[tb_col_seq[j]])){
434                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
435                                                                                                         stmt_ins.setDouble(j+1,Double.parseDouble(colData[fl_col_seq[j]]));
436                                                                                                 } else {
437                                                                                                         stmt_ins.setNull(j+1,java.sql.Types.FLOAT);
438                                                                                                 }
439                                                                                         } else if (CmnUtils.isColBytes(colTypeName[tb_col_seq[j]])){
440                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
441                                                                                                         stmt_ins.setBytes(j+1,CmnUtils.base64ToBytes(colData[fl_col_seq[j]]));
442                                                                                                 } else {
443                                                                                                         stmt_ins.setBytes(j+1,null);
444                                                                                                 }
445                                                                                         } else if (CmnUtils.isColBlob(colTypeName[tb_col_seq[j]])){
446                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
447                                                                                                         stmt_ins.setBytes(j+1,CmnUtils.base64ToBytes(colData[fl_col_seq[j]]));
448                                                                                                 } else {
449                                                                                                         stmt_ins.setBlob(j+1,null,0);
450                                                                                                 }
451                                                                                         } else if (CmnUtils.isColClob(colTypeName[tb_col_seq[j]])){
452                                                                                                 if (!colData[fl_col_seq[j]].equals("")){
453                                                                                                         stmt_ins.setString(j+1,colData[fl_col_seq[j]]);
454                                                                                                 } else {
455                                                                                                         stmt_ins.setClob(j+1,null,0);
456                                                                                                 }
457                                                                                         } else {
458                                                                                                 CmnUtils.errorPrint("\83J\83\89\83\80\82Ì\83f\81[\83^\8c^\82ª\91Î\8fÛ\8aO\82Å\82·\81B[" + colTypeName[tb_col_seq[j]] + "]");
459                                                                                                 break TABLE_LOOP;
460                                                                                         }
461                                                                                 }
462                                                                                 if(isLob){
463                                                                                         stmt_ins.executeUpdate();
464                                                                                 } else {
465                                                                                         stmt_ins.addBatch();
466                                                                                 }
467                                                                                 strMltLine = "";
468                                                                                 tb_rec_count++;
469                                                                         }
470                                                                 }
471                                                                 fl_rec_count++;
472                                                                 if (fl_rec_count % cp.batchCount == 0){
473                                                                         if(!isLob)stmt_ins.executeBatch();
474                                                                         CmnUtils.debugPrint("insert record=" + fl_rec_count);
475                                                                 }
476                                                         }
477                                                         CmnUtils.debugPrint("sql_insert=" + sql_insert);
478                                                         if(!isLob)stmt_ins.executeBatch();
479                                                         dao.commit();
480                                                         System.out.println(String.format("%1$10d",tb_rec_count) + " \8d\83\8d\81[\83h\82³\82ê\82Ü\82µ\82½\81B");
481                                                         CmnUtils.debugPrint("************Record End");
482                                                         if(br != null){
483                                                                 br.close();
484                                                                 br=null;
485                                                         }
486                                                         if(stmt_ins != null){
487                                                                 stmt_ins.close();
488                                                                 stmt_ins=null;
489                                                         }
490                                                         
491                                                 }
492                                         }
493                                 }
494                         } else {
495                                 CmnUtils.errorPrint("\93ü\97Í\8c³\83t\83H\83\8b\83_\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81B[" + folder + "]");
496                         }
497
498                         CmnUtils.infoPrint("\83f\81[\83^\83\8d\81[\83h\82ð\8fI\97¹\82µ\82Ü\82µ\82½\81B");
499
500                 } catch (Exception e) {
501                         try{
502                                 CmnUtils.errorPrint(e.toString());
503                                 e.printStackTrace();
504                                 dao.rollback();
505                         } catch (Exception ee) {}
506                 } finally{
507                         try{
508                                 dao.disconnect();
509                                 if(stmt != null){
510                                         stmt.close();
511                                         stmt=null;
512                                 }
513                                 if(stmt_ins != null){
514                                         stmt_ins.close();
515                                         stmt_ins=null;
516                                 }
517                                 if(br!=null){
518                                         br.close();
519                                         br=null;
520                                 }
521                         } catch (Exception e) {}
522                 }
523         }
524 }