OSDN Git Service

37c29e4ab0f02796de5745e6de0e30a807686609
[rapideact/rapideact.git] / com / rapide_act / DataAccessObjects.java
1 package com.rapide_act;
2
3 import java.io.BufferedInputStream;
4 import java.io.FileInputStream;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.io.File;
8 import java.io.FileWriter;
9 import java.io.BufferedWriter;
10 import java.io.PrintWriter;
11 import java.io.ByteArrayOutputStream;
12 import java.sql.Connection;
13 import java.sql.DriverManager;
14 import java.sql.ResultSet;
15 import java.sql.ResultSetMetaData;
16 import java.sql.SQLException;
17 import java.sql.PreparedStatement;
18 import java.sql.Time;
19 import java.sql.Timestamp;
20 import java.sql.Blob;
21 import java.sql.Clob;
22 import java.io.PrintWriter;
23 import java.util.Date;
24 import java.util.ArrayList;
25 import java.util.Iterator;
26 import java.math.BigInteger;
27 import java.math.BigDecimal;
28 import java.nio.charset.Charset;
29
30 public class DataAccessObjects{
31
32         private String driver = null;
33         private String user = null;
34         private String pass = null;
35         private String url = null;
36         private Connection conn = null;
37         private PreparedStatement stmt = null;
38         private ResultSet rst = null; 
39         private ResultSetMetaData rsmd = null; 
40         private int ColumnCount = 0;
41         private ArrayList<String> alColName = null;
42         private ArrayList<String> alColTypeName = null;
43         private ArrayList<Integer> alColPrecision = null;
44         private ArrayList<Integer> alIsNullable = null;
45         private ArrayList<Boolean> alColMask = null;
46         private ArrayList<Boolean> alColIncl = null;
47         private ArrayList<String> alData = null;
48         private static String sql="select sysdate from dual";
49         private String[] colTypeName = null;
50         private String[] colName = null;
51         private Integer[] colPrecision = null;
52         private Integer[] isNullable = null;
53         private Boolean [] colMask = null;
54         private Boolean [] colIncl = null;
55
56         private String colString = null;
57         private BigDecimal colBigDecimal = null;
58         private Integer colInt = null;
59         private Long colLong = null;
60         private Short colShort = null;
61         private Float colFloat = null;
62         private Double colDouble = null;
63         private java.sql.Timestamp colTimestamp = null;
64         private java.sql.Time colTime = null;
65         private java.sql.Date colDate = null;
66         private java.sql.Date colYear = null;
67         private byte [] colBytes = null;
68         private Blob colBlob = null;
69         private Clob colClob = null;
70         private String tbName = null;
71         private int recCount = 0;
72         private CmnProperty cp = null;
73
74         DataAccessObjects(String _user, String _pass, String _url, String _driver){
75                 user = _user;
76                 pass = _pass;
77                 url = _url;
78                 driver = _driver;
79         }
80
81         DataAccessObjects(CmnProperty _cp){
82                 cp = _cp;
83                 user = cp.user;
84                 pass = cp.pass;
85                 url = cp.url;
86                 driver = cp.driver;
87         }
88
89         public Connection connect() throws Exception{
90
91                 try {
92                         CmnUtils.debugPrint("Start Driver class loading");
93                         Class.forName (driver);
94                         CmnUtils.debugPrint("End Driver class loading");
95                         CmnUtils.debugPrint("Start Connect Database>" + url + "," + user);
96                         conn = DriverManager.getConnection(url, user, pass);
97                         CmnUtils.debugPrint("End Connect Database");
98                         return conn;
99
100                 }
101                 catch (ClassNotFoundException e) {
102                         throw e;
103                 }
104                 catch (IOException e) {
105                         throw e;
106                 }
107                 catch (Exception e){
108                         throw e;
109                 }
110         }
111
112         public PreparedStatement prepareSql(String _sql) throws Exception{
113                 try {
114                         CmnUtils.debugPrint("Start prepared Statement");
115                         CmnUtils.debugPrint(_sql);
116                         stmt = conn.prepareStatement(_sql);
117                         CmnUtils.debugPrint("End prepared Statement");
118                         return stmt;
119                 }
120                 catch (SQLException e) {
121                         throw e;
122                 }
123                 catch (Exception e){
124                         throw e;
125                 }
126         }
127
128         public void executeSql() throws Exception{
129
130                 try {
131                         executeSql(stmt);
132                         CmnUtils.debugPrint("Start get RecordSet");
133                         while (rst.next()) {
134                                 for(int i=0;i<ColumnCount;i++){
135                                         colString = getColString(rst, i + 1, colTypeName[i], isNullable[i], false);
136                                         if (colString != null) {
137                                                 alData.add(colString);
138                                         } else {
139                                                 alData.add("");
140                                         }
141                                 }
142                         }
143                         CmnUtils.debugPrint("End get RecordSet");
144                 }
145                 catch (SQLException e) {
146                         throw e;
147                 }
148                 catch (Exception e){
149                         throw e;
150                 }
151                 finally{
152                         if(rst != null){
153                                 rst.close();
154                                 rst = null;
155                         }
156                         if(stmt != null){
157                                 stmt.close();
158                                 stmt = null;
159                         }
160                 }
161         }
162
163         public void executeSql(PreparedStatement _stmt) throws Exception{
164
165                 try {
166                         CmnUtils.debugPrint("Start execute Query");
167                         rst = _stmt.executeQuery();
168                         CmnUtils.debugPrint("End execute Query");
169                         
170                         CmnUtils.debugPrint("Start get MetaData");
171                         rsmd = rst.getMetaData();
172                         CmnUtils.debugPrint("End get MetaData");
173
174                         CmnUtils.debugPrint("Start get ColumnCount");
175                         ColumnCount = rsmd.getColumnCount();
176                         CmnUtils.debugPrint("End get ColumnCount," + ColumnCount);
177                         alColTypeName = new ArrayList<String>();
178                         alColName = new ArrayList<String>();
179                         alColPrecision = new ArrayList<Integer>();
180                         alIsNullable = new ArrayList<Integer>();
181                         alData = new ArrayList<String>();
182                         for(int i=0;i<ColumnCount;i++){
183                                 alColTypeName.add(rsmd.getColumnTypeName(i + 1));
184                                 alColName.add(rsmd.getColumnName(i + 1));
185                                 alColPrecision.add(rsmd.getPrecision(i + 1));
186                                 alIsNullable.add(rsmd.isNullable(i + 1));
187                         }
188                         colTypeName = (String[])alColTypeName.toArray(new String[0]);
189                         colName = (String[])alColName.toArray(new String[0]);
190                         colPrecision = (Integer[])alColPrecision.toArray(new Integer[0]);
191                         isNullable = (Integer[])alIsNullable.toArray(new Integer[0]);
192                         
193                 }
194                 catch (SQLException e) {
195                         throw e;
196                 }
197                 catch (Exception e){
198                         throw e;
199                 }
200         }
201
202         public void commit() throws Exception{
203                 CmnUtils.debugPrint("Start commit");
204                 conn.commit();
205                 CmnUtils.debugPrint("End commit");
206         }
207
208         public void rollback() throws Exception{
209                 CmnUtils.debugPrint("Start rollback");
210                 conn.rollback();
211                 CmnUtils.debugPrint("End rollback");
212         }
213         
214         public void closeRecordSet() throws Exception{
215                 if(rst != null){
216                         rst.close();
217                         rst = null;
218                 }
219                 if(stmt != null){
220                         stmt.close();
221                         stmt = null;
222                 }
223         }
224
225         public void select(String _sql) throws Exception{
226                 PreparedStatement stmt;
227                 stmt = prepareSql(_sql);
228                 executeSql(stmt);
229                 getRecordToArray();
230                 closeRecordSet();
231         }
232
233         public int getColumnCount() throws Exception{
234                 return ColumnCount;
235         }
236
237         public int getRecCount() throws Exception{
238                 return recCount;
239         }
240
241         public ArrayList<String> getArrayList() throws Exception{
242                 return alData;
243         }
244
245         public ArrayList<String> getArrayColumnNameList() throws Exception{
246                 return alColName;
247         }
248         
249         public ArrayList<String> getArrayColumnTypeNameList() throws Exception{
250                 return alColTypeName;
251         }
252
253         public ArrayList<Integer> getArrayIsNullableList() throws Exception{
254                 return alIsNullable;
255         }
256
257         public ArrayList<Integer> getArrayPrecisionList() throws Exception{
258                 return alColPrecision;
259         }
260
261         public void setArrayColumnMaskList(ArrayList<Boolean> _alColMask) throws Exception{
262                 alColMask = _alColMask;
263                 colMask = (Boolean[])alColMask.toArray(new Boolean[0]);
264         }
265
266         public void setArrayColumnInclList(ArrayList<Boolean> _alColIncl) throws Exception{
267                 alColIncl = _alColIncl;
268                 colIncl = (Boolean[])alColIncl.toArray(new Boolean[0]);
269         }
270
271         public void setTableName(String _tbName) throws Exception{
272                 tbName = _tbName;
273         }
274
275         public ResultSet getResultSet() throws Exception{
276                 return rst;
277         }
278
279         public void getRecordToArray() throws Exception{
280                 try {
281                         CmnUtils.debugPrint("Start get RecordSet to Array");
282                         while (rst.next()) {
283                                 colString = null;
284                                 for(int i=0;i<ColumnCount;i++){
285                                         colString = getColString(rst, i + 1, colTypeName[i], isNullable[i], false);
286                                         CmnUtils.debugPrint("col=" + colString);
287                                         if (colString != null) {
288                                                 alData.add(colString);
289                                         } else {
290                                                 alData.add("");
291                                         }
292                                 }
293                         }
294                         CmnUtils.debugPrint("End get RecordSet to Array");
295                 }
296                 catch (SQLException e) {
297                         throw e;
298                 }
299                 catch (Exception e){
300                         throw e;
301                 }
302         }
303         
304         public void getRecordToPrint(PrintWriter _pw, int _firstCol, int _lastCol) throws Exception{
305                 try {
306                         CmnUtils.debugPrint("Start get Record to Print");
307                         recCount = 0;
308
309                         while (rst.next()) {
310                                 colString = null;
311                                 for(int i=0;i<ColumnCount;i++){
312                                         if (colIncl[i]){
313                                                 colString = getColString(rst, i + 1, colTypeName[i], isNullable[i], colMask[i]);
314
315                                                 if (colString != null) {
316                                                         if(CmnUtils.isFixString(colTypeName[i]) && cp.isSpcPadding)colString = colString + CmnUtils.padSpace(colString, colPrecision[i], Charset.forName(cp.fileEncoding));
317                                                         if (i == _firstCol){
318                                                                 if(cp.isQuotation){
319                                                                         if (_firstCol == _lastCol){
320                                                                                 _pw.print("\"" + colString + "\"" + cp.lineSeparator);
321                                                                         } else {
322                                                                                 _pw.print("\"" + colString);
323                                                                         }
324                                                                 } else {
325                                                                         if (_firstCol == _lastCol){
326                                                                                 _pw.print(colString + cp.lineSeparator);
327                                                                         } else {
328                                                                                 _pw.print(colString);
329                                                                         }
330                                                                 }
331                                                                 
332                                                         } else if (i == _lastCol){
333                                                                 if(cp.isQuotation){
334                                                                         _pw.print("\"" + cp.delimiter + "\"" + colString + "\"" + cp.lineSeparator);
335                                                                 } else {
336                                                                         _pw.print(cp.delimiter + colString + cp.lineSeparator);
337                                                                 }
338                                                         } else {
339                                                                 if(cp.isQuotation){
340                                                                         _pw.print("\"" + cp.delimiter + "\"" + colString);
341                                                                 } else {
342                                                                         _pw.print(cp.delimiter + colString);
343                                                                 }
344                                                         }
345                                                         
346                                                         
347
348                                                 } else {
349                                                         if (i == _firstCol){
350                                                                 if(cp.isQuotation){
351                                                                         if (_firstCol == _lastCol){
352                                                                                 _pw.print("\"" + cp.nullMark + "\"" + cp.lineSeparator);
353                                                                         } else {
354                                                                                 _pw.print("\"" + cp.nullMark);
355                                                                         }
356                                                                 } else {
357                                                                         if (_firstCol == _lastCol){
358                                                                                 _pw.print(cp.nullMark + cp.lineSeparator);
359                                                                         } else {
360                                                                                 _pw.print(cp.nullMark);
361                                                                         }
362                                                                 }
363                                                         } else if (i == _lastCol){
364                                                                 if(cp.isQuotation){
365                                                                         _pw.print("\"" + cp.delimiter + "\"" + cp.nullMark + "\"" + cp.lineSeparator);
366                                                                 } else {
367                                                                         _pw.print(cp.delimiter + cp.nullMark + cp.lineSeparator);
368                                                                 }
369                                                         } else {
370                                                                 if(cp.isQuotation){
371                                                                         _pw.print("\"" + cp.delimiter + "\"" + cp.nullMark);
372                                                                 } else {
373                                                                         _pw.print(cp.delimiter + cp.nullMark);
374                                                                 }
375                                                         }
376                                                 }
377                                         }
378                                 }
379                                 recCount++;
380                         }
381                         CmnUtils.debugPrint("End get Record to Print");
382                 }
383                 catch (SQLException e) {
384                         throw e;
385                 }
386                 catch (Exception e){
387                         throw e;
388                 }
389         }
390
391         private String getColString(ResultSet _rst, int _rec_cnt, String _colTypeName, Integer _isNullable, Boolean _colMask) throws Exception{
392                 colString = null;
393                 colTimestamp = null;
394                 colTime = null;
395                 colDate = null;
396                 colYear = null;
397                 colBigDecimal = null;
398                 colInt = null;
399                 colLong = null;
400                 colShort = null;
401                 colFloat = null;
402                 colDouble = null;
403                 colBytes = null;
404                 colBlob = null;
405                 colClob = null;
406                 ByteArrayOutputStream baos = null;
407                 InputStream is = null;
408
409                 if (CmnUtils.isColString(_colTypeName)) {
410                         colString = _rst.getString(_rec_cnt);
411                         if (colString != null) {
412                                 if(cp.isQuotation){
413                                         colString =colString.trim().replaceAll("\0","").replaceAll("\"","\"\"");
414                                 } else {
415                                         colString =colString.trim().replaceAll("\0","");
416                                 }
417                                 if(cp.isMask){
418                                         if(_colMask==true){
419                                                 StringBuffer sb = new StringBuffer();
420                                                 for(int j=0;j<colString.length();j++){
421                                                         if((cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALT]) && 
422                                                                         (j % 2) == 1) || 
423                                                            (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_EDGE]) && 
424                                                                         !(j == 0 || j == colString.length() - 1) ||
425                                                            (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALL]))
426                                                            )
427                                                         ){
428                                                                         if(CmnUtils.isHankaku(colString.charAt(j))){
429                                                                                 sb.append(cp.singleByteMaskChar);
430                                                                         } else {
431                                                                                 sb.append(cp.doubleByteMaskChar);
432                                                                         }
433                                                         } else {
434                                                                 sb.append(colString.charAt(j));
435                                                         }
436                                                 }
437                                                 colString = sb.toString();
438                                         }
439                                 }
440                                 if(colString.equals(""))colString = " ";
441                         }
442                 } else if (CmnUtils.isColDate(_colTypeName)) {
443                         colDate = _rst.getDate(_rec_cnt);
444                         if (colDate != null) {
445                                 colString = colDate.toString();
446                         }
447                 } else if (CmnUtils.isColYear(_colTypeName)) {
448                         colYear = _rst.getDate(_rec_cnt);
449                         if (colYear != null) {
450                                 colString = colYear.toString().substring(0, 4);
451                         }
452                 } else if (CmnUtils.isColTimestamp(_colTypeName)) {
453                         colTimestamp = _rst.getTimestamp(_rec_cnt);
454                         if (colTimestamp != null) {
455                                 colString = colTimestamp.toString();
456                         }
457                 } else if (CmnUtils.isColTime(_colTypeName)) {
458                         colTime = _rst.getTime(_rec_cnt);
459                         if (colTime != null) {
460                                 colString = colTime.toString();
461                         }
462                 } else if (CmnUtils.isColBigDecimal(_colTypeName)) {
463                         colBigDecimal = _rst.getBigDecimal(_rec_cnt);
464                         if (colBigDecimal != null) {
465                                 colString = colBigDecimal.toString();
466                         }
467                 } else if (CmnUtils.isColShort(_colTypeName)) {
468                         colShort = _rst.getShort(_rec_cnt);
469                         if (colShort != null) {
470                                 colString = colShort.toString();
471                         }
472                 } else if (CmnUtils.isColInt(_colTypeName)) {
473                         colInt = _rst.getInt(_rec_cnt);
474                         if (colInt != null) {
475                                 colString = colInt.toString();
476                         }
477                 } else if (CmnUtils.isColLong(_colTypeName)) {
478                         colLong = _rst.getLong(_rec_cnt);
479                         if (colLong != null) {
480                                 colString = colLong.toString();
481                         }
482                 } else if (CmnUtils.isColFloat(_colTypeName)) {
483                         colFloat = _rst.getFloat(_rec_cnt);
484                         if (colFloat != null) {
485                                 colString = colFloat.toString();
486                         }
487                 } else if (CmnUtils.isColDouble(_colTypeName)) {
488                         colDouble = _rst.getDouble(_rec_cnt);
489                         if (colDouble != null) {
490                                 colString = colDouble.toString();
491                         }
492                 } else if (CmnUtils.isColBytes(_colTypeName)) {
493                         colBytes = _rst.getBytes(_rec_cnt);
494                         if (colBytes != null) {
495                                 colString = CmnUtils.bytesToBase64(colBytes);
496                         }
497                 } else if (CmnUtils.isColBlob(_colTypeName)) {
498                         colBlob = _rst.getBlob(_rec_cnt);
499                         if (colBlob != null) {
500                                 is = colBlob.getBinaryStream();
501                                 baos = new ByteArrayOutputStream();
502                                 int len = -1;
503                                 colBytes = new byte[8192];
504                                 while ((len = is.read(colBytes)) != -1) {
505                                         baos.write(colBytes,0,len);
506                                 }
507                                 colBytes = baos.toByteArray();
508                                 colString = CmnUtils.bytesToBase64(colBytes);
509                                 is.close();
510                                 baos.close();
511                                 is = null;
512                                 baos = null;
513                         }
514                 } else if (CmnUtils.isColClob(_colTypeName)) {
515                         colClob = _rst.getClob(_rec_cnt);
516                         if (colClob != null) {
517                                 colString = CmnUtils.clobToString(colClob);
518                         }
519                 } else {
520                         throw new Exception("\83J\83\89\83\80\82Ì\83f\81[\83^\8c^\82ª\91Î\8fÛ\8aO\82Å\82·\81B[" + _colTypeName  + "]");
521                 }
522                 return colString;
523         }
524
525         protected void setColString(PreparedStatement stmt_ins, String [] colData, int ins_col_count, int [] tb_col_seq, int [] fl_col_seq) throws Exception{
526
527                 if (CmnUtils.isColString(colTypeName[tb_col_seq[ins_col_count]])){
528                         if(cp.isMask){
529                                 if(
530                                         (cp.isInclColsMask &&
531                                          !cp.isExclColsMask && 
532                                          CmnUtils.isMatch(cp.inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[ins_col_count]].toUpperCase())
533                                         ) ||
534                                         (cp.isInclColsMask &&
535                                          cp.isExclColsMask && 
536                                          CmnUtils.isMatch(cp.inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[ins_col_count]].toUpperCase()) &&
537                                          !CmnUtils.isMatch(cp.exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[ins_col_count]].toUpperCase())
538                                         ) ||
539                                         (!cp.isInclColsMask &&
540                                          cp.isExclColsMask && 
541                                          !CmnUtils.isMatch(cp.exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[ins_col_count]].toUpperCase())
542                                         )
543                                 ){
544                                         StringBuffer sb = new StringBuffer();
545                                         for(int l=0;l<colData[fl_col_seq[ins_col_count]].length();l++){
546                                                 if((cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALT]) && 
547                                                                 (l % 2) == 1) || 
548                                                    (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_EDGE]) && 
549                                                                 !(l == 0 || ins_col_count == colData[fl_col_seq[ins_col_count]].length() - 1) ||
550                                                    (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALL]))
551                                                    )
552                                                 ){
553                                                         if(CmnUtils.isHankaku(colData[fl_col_seq[ins_col_count]].charAt(l))){
554                                                                 sb.append(cp.singleByteMaskChar);
555                                                         } else {
556                                                                 sb.append(cp.doubleByteMaskChar);
557                                                         }
558                                                 } else {
559                                                         sb.append(colData[fl_col_seq[ins_col_count]].charAt(l));
560                                                 }
561                                         }
562                                         colData[fl_col_seq[ins_col_count]] = sb.toString();
563                                 }
564                         }
565                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
566                                 if(cp.isQuotation){
567                                         stmt_ins.setString(ins_col_count+1,colData[fl_col_seq[ins_col_count]].replaceAll("\"\"","\""));
568                                 } else {
569                                         stmt_ins.setString(ins_col_count+1,colData[fl_col_seq[ins_col_count]]);
570                                 }
571                         } else {
572                                 stmt_ins.setString(ins_col_count+1,null);
573                         }
574                 } else if (CmnUtils.isColDate(colTypeName[tb_col_seq[ins_col_count]])){
575                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
576                                 stmt_ins.setDate(ins_col_count+1,java.sql.Date.valueOf(colData[fl_col_seq[ins_col_count]]));
577                         } else {
578                                 stmt_ins.setDate(ins_col_count+1,null);
579                         }
580                 } else if (CmnUtils.isColYear(colTypeName[tb_col_seq[ins_col_count]])){
581                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
582                                 stmt_ins.setString(ins_col_count+1,colData[fl_col_seq[ins_col_count]]);
583                         } else {
584                                 stmt_ins.setDate(ins_col_count+1,null);
585                         }
586                 } else if (CmnUtils.isColTime(colTypeName[tb_col_seq[ins_col_count]])){
587                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
588                                 stmt_ins.setTime(ins_col_count+1,java.sql.Time.valueOf(colData[fl_col_seq[ins_col_count]]));
589                         } else {
590                                 stmt_ins.setTime(ins_col_count+1,null);
591                         }
592                 } else if (CmnUtils.isColTimestamp(colTypeName[tb_col_seq[ins_col_count]])){
593                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
594                                 stmt_ins.setTimestamp(ins_col_count+1,java.sql.Timestamp.valueOf(colData[fl_col_seq[ins_col_count]]));
595                                 //CmnUtils.debugPrint("Timestamp=" + colData[fl_col_seq[ins_col_count]]);
596                         } else {
597                                 stmt_ins.setTimestamp(ins_col_count+1,null);
598                         }
599                 } else if (CmnUtils.isColBigDecimal(colTypeName[tb_col_seq[ins_col_count]])){
600                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
601                                 stmt_ins.setBigDecimal(ins_col_count+1,new BigDecimal(colData[fl_col_seq[ins_col_count]]));
602                         } else {
603                                 stmt_ins.setNull(ins_col_count+1,java.sql.Types.DECIMAL);
604                         }
605                 } else if (CmnUtils.isColShort(colTypeName[tb_col_seq[ins_col_count]])){
606                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
607                                 stmt_ins.setShort(ins_col_count+1,Short.parseShort(colData[fl_col_seq[ins_col_count]]));
608                         } else {
609                                 stmt_ins.setNull(ins_col_count+1,java.sql.Types.SMALLINT);
610                         }
611                 } else if (CmnUtils.isColInt(colTypeName[tb_col_seq[ins_col_count]])){
612                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
613                                 stmt_ins.setInt(ins_col_count+1,Integer.parseInt(colData[fl_col_seq[ins_col_count]]));
614                         } else {
615                                 stmt_ins.setNull(ins_col_count+1,java.sql.Types.INTEGER);
616                         }
617                 } else if (CmnUtils.isColLong(colTypeName[tb_col_seq[ins_col_count]])){
618                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
619                                 stmt_ins.setLong(ins_col_count+1,Long.parseLong(colData[fl_col_seq[ins_col_count]]));
620                         } else {
621                                 stmt_ins.setNull(ins_col_count+1,java.sql.Types.BIGINT);
622                         }
623                 } else if (CmnUtils.isColFloat(colTypeName[tb_col_seq[ins_col_count]])){
624                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
625                                 stmt_ins.setFloat(ins_col_count+1,Float.parseFloat(colData[fl_col_seq[ins_col_count]]));
626                         } else {
627                                 stmt_ins.setNull(ins_col_count+1,java.sql.Types.REAL);
628                         }
629                 } else if (CmnUtils.isColDouble(colTypeName[tb_col_seq[ins_col_count]])){
630                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
631                                 stmt_ins.setDouble(ins_col_count+1,Double.parseDouble(colData[fl_col_seq[ins_col_count]]));
632                         } else {
633                                 stmt_ins.setNull(ins_col_count+1,java.sql.Types.FLOAT);
634                         }
635                 } else if (CmnUtils.isColBytes(colTypeName[tb_col_seq[ins_col_count]])){
636                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
637                                 stmt_ins.setBytes(ins_col_count+1,CmnUtils.base64ToBytes(colData[fl_col_seq[ins_col_count]]));
638                         } else {
639                                 stmt_ins.setBytes(ins_col_count+1,null);
640                         }
641                 } else if (CmnUtils.isColBlob(colTypeName[tb_col_seq[ins_col_count]])){
642                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
643                                 stmt_ins.setBytes(ins_col_count+1,CmnUtils.base64ToBytes(colData[fl_col_seq[ins_col_count]]));
644                         } else {
645                                 stmt_ins.setBlob(ins_col_count+1,null,0);
646                         }
647                 } else if (CmnUtils.isColClob(colTypeName[tb_col_seq[ins_col_count]])){
648                         if (!colData[fl_col_seq[ins_col_count]].equals("")){
649                                 stmt_ins.setString(ins_col_count+1,colData[fl_col_seq[ins_col_count]]);
650                         } else {
651                                 stmt_ins.setClob(ins_col_count+1,null,0);
652                         }
653                 } else {
654                         throw new Exception("\83J\83\89\83\80\82Ì\83f\81[\83^\8c^\82ª\91Î\8fÛ\8aO\82Å\82·\81B[" + colTypeName[tb_col_seq[ins_col_count]] + "]");
655                 }
656         }
657
658         public void disconnect() throws Exception{
659
660                 try {
661                         CmnUtils.debugPrint("Start disconnect database");
662                         conn.close();
663                         CmnUtils.debugPrint("End disconnect database");
664                         
665                 }
666                 catch (SQLException e) {
667                         throw e;
668                 }
669                 catch (Exception e){
670                         throw e;
671                 }
672                 finally{
673                         if(conn != null){
674                                 conn.close();
675                                 conn = null;
676                         }
677                 }
678         }
679
680 }
681