OSDN Git Service

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