OSDN Git Service

AAA
authorkuboryu <kuboryu@yahoo.co.jp>
Sun, 22 Jan 2017 07:28:50 +0000 (16:28 +0900)
committerkuboryu <kuboryu@yahoo.co.jp>
Sun, 22 Jan 2017 07:28:50 +0000 (16:28 +0900)
com/rapide_act/CmnUtils.java [new file with mode: 0644]
com/rapide_act/DataAccessObjects.java [new file with mode: 0644]
com/rapide_act/RapideLoader.java [new file with mode: 0644]
com/rapide_act/RapideUnloader.java [new file with mode: 0644]

diff --git a/com/rapide_act/CmnUtils.java b/com/rapide_act/CmnUtils.java
new file mode 100644 (file)
index 0000000..68f8d75
--- /dev/null
@@ -0,0 +1,536 @@
+package com.rapide_act;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.BufferedWriter;
+import java.io.BufferedReader;
+import java.io.PrintWriter;
+import java.io.PrintWriter;
+import java.io.ByteArrayOutputStream;
+import java.util.Date;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Timestamp;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.math.BigDecimal;
+import java.util.regex.Pattern;
+import org.apache.commons.codec.binary.Base64;
+
+public class CmnUtils{
+       
+       public static void writeCsv(String _file, int _columnCount, ArrayList<String> _alData) throws Exception{
+               PrintWriter pw = null;
+               try {
+                       debugPrint("Start write csv," + "columnCount=" + _columnCount);
+                       pw = new PrintWriter(new BufferedWriter(new FileWriter(new File(_file))));
+                       for(int i=0;i<_alData.size();i++){
+                               pw.print(_alData.get(i).replaceAll("\n","\r\n"));
+                               if (_columnCount == 1){
+                                       pw.println("");
+                               } else {
+                                       if ((i+1) % _columnCount == 0 && i > 0){
+                                               pw.println("");
+                                       } else {
+                                               pw.print(",");
+                                       }
+                               }
+                       }
+                       pw.close();
+                       debugPrint("End write csv");
+               }
+               catch (Exception e){
+                       throw e;
+               }
+       }
+
+       public static void printConsole(int _columnCount, ArrayList<String> _alData) throws Exception{
+               try {
+                       debugPrint("Start console print");
+                       for(int i=0;i<_alData.size();i++){
+                               System.out.print(_alData.get(i).replaceAll("\n","\r\n"));
+                               if (_columnCount == 1){
+                                       System.out.println("");
+                               } else {
+                                       if ((i+1) % _columnCount == 0 && i > 0){
+                                               System.out.println("");
+                                       } else {
+                                               System.out.print(",");
+                                       }
+                               }
+                       }
+                       debugPrint("End console print");
+               }
+               catch (Exception e){
+                       throw e;
+               }
+       }
+
+       public static void debugPrint(String _message) throws Exception{
+               if(System.getProperty("debug")!=null)System.out.println(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()) + " [DEBUG] " + _message);
+       }
+
+       public static void debugPrinting(String _message) throws Exception{
+               if(System.getProperty("debug")!=null)System.out.print(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()) + " [DEBUG] " + _message);
+       }
+
+       public static void infoPrint(String _message) throws Exception{
+               System.out.println(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()) + " [INFO] " + _message);
+       }
+       public static void infoPrinting(String _message) throws Exception{
+               System.out.print(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()) + " [INFO] " + _message);
+       }
+
+       public static void errorPrint(String _message) throws Exception{
+               System.out.println(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()) + " [ERROR] " + _message);
+       }
+
+       public static String getTimestamp() throws Exception{
+               return (new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()));
+       }
+
+       public static String getYmdhm() throws Exception{
+               return (new java.text.SimpleDateFormat("yyyyMMddHHmm").format(new Date()));
+       }
+
+       public static int getArrayRowNo(ArrayList<String> _al, int _alMember, int _seq, String _value) throws Exception {
+               int ret = -1;
+               for(int i=0;i<_al.size()/_alMember;i++){
+                       if(_al.get(i*_alMember + _seq).equals(_value)){
+                               ret = i;
+                               break;
+                       }
+               }
+               return ret;
+       }
+
+       public static String [] getArrayRowData(ArrayList<String> _al, int _alMember, int _row) throws Exception {
+               String [] rowData = new String[_alMember];
+               int colNo = 0;
+               for(int i=_row*_alMember;i<_row*_alMember + _alMember;i++){
+                       rowData[colNo] = _al.get(i);
+                       colNo++;
+               }
+               return rowData;
+       }
+
+       public static String [] splitCsv(String _line) throws Exception {
+               return split(_line, ",");
+       }
+
+       public static String [] splitSpace(String _line) throws Exception {
+               return split(_line, " ");
+       }
+
+       public static String [] splitDot(String _line) throws Exception {
+               return split(_line, "\\.");
+       }
+       
+       public static String [] splitCrLf(String _line) throws Exception {
+               return split(_line, "\r\n");
+       }
+
+       public static String [] splitSlash(String _line) throws Exception {
+               return split(_line, "/");
+       }
+
+       public static String [] splitTab(String _line) throws Exception {
+               return split(_line, "\t");
+       }
+
+       public static String [] split(String _line, String _delim) throws Exception {
+               String [] strSplit;
+               strSplit = _line.split(_delim, -1);
+               return strSplit;
+       }
+       
+       public static boolean isLastCrLf(String _str) throws Exception{
+               boolean rtn = false;
+               char[] charArray = _str.toCharArray();
+               if (_str.length() > 1){
+                       if (charArray[_str.length() - 2] != '\r' && charArray[_str.length() - 1] != '\n'){
+                               rtn = true;
+                       }
+               }
+               return rtn;
+       }
+
+       public static char[] hexArray = "0123456789ABCDEF".toCharArray();
+       public static String bytesToHex(byte[] _bytes){
+               char[] hexChars = new char[_bytes.length * 2];
+               for(int j=0;j<_bytes.length;j++){
+                       int v = _bytes[j] & 0xFF;
+                       hexChars[j * 2] = hexArray[v >>> 4];
+                       hexChars[j * 2 + 1] = hexArray[v & 0x0F];
+               }
+               return new String(hexChars);
+       }
+       public static byte[] hexToBytes(String _hex){
+               byte[] bytes = new byte[_hex.length()/2];
+               for(int j=0;j<_hex.length()/2;j++){
+                       bytes[j] = (byte)Integer.parseInt(_hex.substring(j*2,(j+1)*2),16);
+               }
+               return bytes;
+       }
+
+       public static String bytesToBase64(byte[] _bytes){
+               return new String(Base64.encodeBase64(_bytes));
+       }
+       public static byte[] base64ToBytes(String _base64){
+               return Base64.decodeBase64(_base64.getBytes());
+       }
+
+       public static String clobToString(Clob _clob) throws Exception{
+               return _clob.getSubString(1, (int)_clob.length());
+       }
+
+       public static String getLineSeparator(){
+               return System.getProperty("line.separator");
+       }
+
+       public static boolean isMatch(String [] _tables, String _table) throws Exception{
+               boolean rtn = false;
+               Pattern p = null;
+               Matcher m = null;
+               if(_tables != null && _tables.length>0){
+                       for (int i = 0; i < _tables.length; i++) {
+                               String s = _tables[i].replace("*",".*");
+                               //debugPrint("s="+s);
+                               //p = Pattern.compile(s);
+                               //m = p.matches(_table);
+                               if(_table.matches(s)){
+                                       rtn = true;
+                                       break;
+                               }
+                       }
+               }
+               return rtn;
+       }
+       
+       public static String getYesNo(boolean _bln){
+               String retVal;
+               if(_bln){
+                       retVal = "Yes";
+               } else {
+                       retVal = "No";
+               }
+               return retVal;
+       }
+
+       public static boolean isMatch(String [] _tabCols, String _table, String _col) throws Exception{
+               boolean rtn = false;
+               Pattern p = null;
+               Matcher m = null;
+               if(_tabCols != null && _tabCols.length>0){
+                       for (int i = 0; i < _tabCols.length; i++) {
+                               String s = null;
+                               String [] tbCols = splitDot(_tabCols[i]);
+                               //infoPrint("length="+tbCols.length);
+                               if (tbCols.length == 1){
+                                       s = _tabCols[i].replace("*",".*");
+                                       if(_col.matches(s)){
+                                               rtn = true;
+                                               break;
+                                       }
+                               } else if (tbCols.length == 2){
+                                       if(_table.matches(tbCols[0].replace("*",".*")) && _col.matches(tbCols[1].replace("*",".*"))){
+                                               rtn = true;
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               return rtn;
+       }
+
+       public static boolean isJapanese(String _str) throws Exception{
+               for(int i=0;i<_str.length();i++){
+                       char chr = _str.charAt(i);
+                       Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(chr);
+                       if (Character.UnicodeBlock.HIRAGANA.equals(unicodeBlock))return true;
+                       if (Character.UnicodeBlock.KATAKANA.equals(unicodeBlock))return true;
+                       if (Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS.equals(unicodeBlock))return true;
+                       if (Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS.equals(unicodeBlock))return true;
+                       if (Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION.equals(unicodeBlock))return true;
+               }
+               return false;
+       }
+
+       public static boolean isHankaku(char _chr) throws Exception{
+               if((_chr <= '\u007e') || (_chr == '\u00a5') || (_chr == '\u203e') || (_chr >= '\uff61' && _chr <= '\uff9f')){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColString(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("XML") ||
+                       _str.toUpperCase().equals("UNIQUEIDENTIFIER") ||
+                       _str.toUpperCase().equals("TEXT") ||
+                       _str.toUpperCase().equals("NTEXT") ||
+                       _str.toUpperCase().equals("CHAR") ||
+                       _str.toUpperCase().equals("NCHAR") ||
+                       _str.toUpperCase().equals("VARCHAR") ||
+                       _str.toUpperCase().equals("VARCHAR2") ||
+                       _str.toUpperCase().equals("NVARCHAR") ||
+                       _str.toUpperCase().equals("NVARCHAR2") ||
+                       _str.toUpperCase().equals("MVARCHAR") ||
+                       _str.toUpperCase().equals("BIGINT") ||
+                       _str.toUpperCase().equals("LONG")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColDate(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("DATE")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColTime(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("TIME")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColTimestamp(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("TIMESTAMP") ||
+                       _str.toUpperCase().equals("SMALLDATETIME") ||
+                       _str.toUpperCase().equals("DATETIME") ||
+                       _str.toUpperCase().equals("DATETIME2")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColBigDecimal(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("NUMERIC") ||
+                       _str.toUpperCase().equals("NUMBER") ||
+                       _str.toUpperCase().equals("MONEY") ||
+                       _str.toUpperCase().equals("SMALLMONEY") ||
+                       _str.toUpperCase().equals("DECIMAL")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColShort(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("TINYINT") ||
+                       _str.toUpperCase().equals("SMALLINT")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColInt(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("INTEGER") ||
+                       _str.toUpperCase().equals("INT")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColFloat(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("REAL") ||
+                       _str.toUpperCase().equals("SMALLFLT")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColDouble(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("FLOAT") ||
+                       _str.toUpperCase().equals("DOUBLE PRECISION")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColBytes(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("RAW") ||
+                       _str.toUpperCase().equals("BINARY")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColBlob(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("BLOB") ||
+                       _str.toUpperCase().equals("VARBINARY") ||
+                       _str.toUpperCase().equals("UDT") ||
+                       _str.toUpperCase().equals("IMAGE")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isColClob(String _str) throws Exception{
+               if(
+                       _str.toUpperCase().equals("CLOB") ||
+                       _str.toUpperCase().equals("NCLOB")){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isLob(String _str) throws Exception{
+               if(
+                       isColClob(_str) || isColBlob(_str)){
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static String[] getSystemProperty(String _str) throws Exception{
+               String [] retValue = null;
+               if(System.getProperty(_str)!=null){
+                       retValue = splitCsv(System.getProperty(_str).toUpperCase());
+               }
+               return retValue;
+       }
+
+       public static String getSystemProperty(String _str, String _strDefault) throws Exception{
+               String retValue = _strDefault;
+               if(System.getProperty(_str)!=null){
+                       retValue = System.getProperty(_str).toUpperCase();
+               }
+               return retValue;
+       }
+
+       public static char getSystemProperty(String _str, char _chrDefault) throws Exception{
+               char retValue = _chrDefault;
+               if(System.getProperty(_str)!=null){
+                       retValue = System.getProperty(_str).toUpperCase().charAt(0);
+               }
+               return retValue;
+       }
+
+       public static boolean getSystemProperty(String _str, boolean _blnDefault) throws Exception{
+               boolean retValue = _blnDefault;
+               if(System.getProperty(_str)!=null){
+                       if(System.getProperty(_str).toUpperCase().equals("Y")){
+                               retValue = true;
+                       } else if (System.getProperty(_str).toUpperCase().equals("N")){
+                               retValue = false;
+                       } else {
+                               retValue = true;
+                       }
+               }
+               return retValue;
+       }
+
+       public static String getSeparator(String _str, String _strDefault) throws Exception{
+               String retValue = _strDefault;
+               if(System.getProperty(_str)!=null){
+                       String _sprtr = System.getProperty(_str);
+                       char [] chr = new char[_sprtr.length()];
+                       int j = 0;
+                       for(int i=0;i<_sprtr.length();i++){
+                               if (i < _sprtr.length() - 1){
+                                       if (_sprtr.charAt(i) == '\\'){
+                                               switch(_sprtr.charAt(i + 1)){
+                                                       case 't':
+                                                               chr[j] = 0x09;
+                                                               i++;
+                                                               j++;
+                                                               break;
+                                                       default:
+                                                               chr[j] = _sprtr.charAt(i);
+                                                               j++;
+                                                               break;
+                                               }
+                                       } else {
+                                               chr[j] = _sprtr.charAt(i);
+                                               j++;
+                                       }
+                               } else {
+                                       chr[j] = _sprtr.charAt(i);
+                                       j++;
+                               }
+                       }
+                       char [] chr2 = new char[j];
+                       for(int i=0;i<j;i++){
+                               chr2[i] = chr[i];
+                       }
+                       retValue = String.valueOf(chr2);
+               }
+               return retValue;
+       }
+
+       public static String getLineSeparator(String _str, String _strDefault) throws Exception{
+               String retValue = _strDefault;
+               if(System.getProperty(_str)!=null){
+                       String _sprtr = System.getProperty(_str);
+                       char [] chr = new char[_sprtr.length()];
+                       int j = 0;
+                       for(int i=0;i<_sprtr.length();i++){
+                               if (i < _sprtr.length() - 1){
+                                       if (_sprtr.charAt(i) == '\\'){
+                                               switch(_sprtr.charAt(i + 1)){
+                                                       case 'r':
+                                                               chr[j] = 0x0d;
+                                                               i++;
+                                                               j++;
+                                                               break;
+                                                       case 'n':
+                                                               chr[j] = 0x0a;
+                                                               i++;
+                                                               j++;
+                                                               break;
+                                               }
+                                       }
+                               }
+                       }
+                       char [] chr2 = new char[j];
+                       for(int i=0;i<j;i++){
+                               chr2[i] = chr[i];
+                       }
+                       retValue = String.valueOf(chr2);
+               }
+               return retValue;
+       }
+
+
+}
diff --git a/com/rapide_act/DataAccessObjects.java b/com/rapide_act/DataAccessObjects.java
new file mode 100644 (file)
index 0000000..13ab22b
--- /dev/null
@@ -0,0 +1,533 @@
+package com.rapide_act;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.BufferedWriter;
+import java.io.PrintWriter;
+import java.io.ByteArrayOutputStream;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.io.PrintWriter;
+import java.util.Date;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.math.BigDecimal;
+
+public class DataAccessObjects{
+
+       private String driver = null;
+       private String user = null;
+       private String pass = null;
+       private String url = null;
+       private Connection conn = null;
+       private PreparedStatement stmt = null;
+       private ResultSet rst = null; 
+       private ResultSetMetaData rsmd = null; 
+       private int ColumnCount = 0;
+       private ArrayList<String> alColName = null;
+       private ArrayList<String> alColTypeName = null;
+       private ArrayList<Integer> alIsNullable = null;
+       private ArrayList<Boolean> alColMask = null;
+       private ArrayList<Boolean> alColIncl = null;
+       private ArrayList<String> alData = null;
+       private static String sql="select sysdate from dual";
+       private String[] colTypeName = null;
+       private String[] colName = null;
+       private Integer[] isNullable = null;
+       private Boolean [] colMask = null;
+       private Boolean [] colIncl = null;
+
+       private String colString = null;
+       private BigDecimal colBigDecimal = null;
+       private Integer colInt = null;
+       private Short colShort = null;
+       private Float colFloat = null;
+       private Double colDouble = null;
+       private java.sql.Timestamp colTimestamp = null;
+       private java.sql.Time colTime = null;
+       private java.sql.Date colDate = null;
+       private byte [] colBytes = null;
+       private Blob colBlob = null;
+       private Clob colClob = null;
+       private int recCount = 0;
+       private InputStream is = null;
+       private ByteArrayOutputStream baos = null;
+       private boolean isQuotation = true;
+       private boolean isMask = false;
+       private String inclMaskCols = null;
+       private String exclMaskCols = null;
+       private String tbName = null;
+       private String nullMark = "";
+       private static final int MASK_PTN_ALL = 0;
+       private static final int MASK_PTN_ALT = 1;
+       private static final int MASK_PTN_EDGE = 2;
+       private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
+       
+       DataAccessObjects(String _user, String _pass, String _url, String _driver){
+               user = _user;
+               pass = _pass;
+               url = _url;
+               driver = _driver;
+       }
+
+       public Connection connect() throws Exception{
+
+               try {
+                       CmnUtils.debugPrint("Start Driver class loading");
+                       Class.forName (driver);
+                       CmnUtils.debugPrint("End Driver class loading");
+                       CmnUtils.debugPrint("Start Connect Database>" + url + "," + user);
+                       conn = DriverManager.getConnection(url, user, pass);
+                       CmnUtils.debugPrint("End Connect Database");
+                       return conn;
+
+               }
+               catch (ClassNotFoundException e) {
+                       throw e;
+               }
+               catch (IOException e) {
+                       throw e;
+               }
+               catch (Exception e){
+                       throw e;
+               }
+       }
+
+       public PreparedStatement prepareSql(String _sql) throws Exception{
+               try {
+                       CmnUtils.debugPrint("Start prepared Statement");
+                       CmnUtils.debugPrint(_sql);
+                       stmt = conn.prepareStatement(_sql);
+                       CmnUtils.debugPrint("End prepared Statement");
+                       return stmt;
+               }
+               catch (SQLException e) {
+                       throw e;
+               }
+               catch (Exception e){
+                       throw e;
+               }
+       }
+
+       public void executeSql() throws Exception{
+
+               try {
+                       executeSql(stmt);
+                       CmnUtils.debugPrint("Start get RecordSet");
+                       while (rst.next()) {
+                               for(int i=0;i<ColumnCount;i++){
+                                       colString = getColString(rst, i + 1, colTypeName[i], isNullable[i], false);
+                                       if (colString != null) {
+                                               alData.add(colString);
+                                       } else {
+                                               alData.add("");
+                                       }
+                               }
+                       }
+                       CmnUtils.debugPrint("End get RecordSet");
+               }
+               catch (SQLException e) {
+                       throw e;
+               }
+               catch (Exception e){
+                       throw e;
+               }
+               finally{
+                       if(rst != null){
+                               rst.close();
+                               rst = null;
+                       }
+                       if(stmt != null){
+                               stmt.close();
+                               stmt = null;
+                       }
+               }
+       }
+
+       public void executeSql(PreparedStatement _stmt) throws Exception{
+
+               try {
+                       CmnUtils.debugPrint("Start execute Query");
+                       rst = _stmt.executeQuery();
+                       CmnUtils.debugPrint("End execute Query");
+                       
+                       CmnUtils.debugPrint("Start get MetaData");
+                       rsmd = rst.getMetaData();
+                       CmnUtils.debugPrint("End get MetaData");
+
+                       CmnUtils.debugPrint("Start get ColumnCount");
+                       ColumnCount = rsmd.getColumnCount();
+                       CmnUtils.debugPrint("End get ColumnCount," + ColumnCount);
+                       alColTypeName = new ArrayList<String>();
+                       alColName = new ArrayList<String>();
+                       alIsNullable = new ArrayList<Integer>();
+                       alData = new ArrayList<String>();
+                       for(int i=0;i<ColumnCount;i++){
+                               alColTypeName.add(rsmd.getColumnTypeName(i + 1));
+                               alColName.add(rsmd.getColumnName(i + 1));
+                               alIsNullable.add(rsmd.isNullable(i + 1));
+                       }
+                       colTypeName = (String[])alColTypeName.toArray(new String[0]);
+                       colName = (String[])alColName.toArray(new String[0]);
+                       isNullable = (Integer[])alIsNullable.toArray(new Integer[0]);
+                       
+               }
+               catch (SQLException e) {
+                       throw e;
+               }
+               catch (Exception e){
+                       throw e;
+               }
+       }
+
+       public void commit() throws Exception{
+               CmnUtils.debugPrint("Start commit");
+               conn.commit();
+               CmnUtils.debugPrint("End commit");
+       }
+
+       public void rollback() throws Exception{
+               CmnUtils.debugPrint("Start rollback");
+               conn.rollback();
+               CmnUtils.debugPrint("End rollback");
+       }
+       
+       public void closeRecordSet() throws Exception{
+               if(rst != null){
+                       rst.close();
+                       rst = null;
+               }
+               if(stmt != null){
+                       stmt.close();
+                       stmt = null;
+               }
+       }
+
+       public void select(String _sql) throws Exception{
+               PreparedStatement stmt;
+               stmt = prepareSql(_sql);
+               executeSql(stmt);
+               getRecordToArray();
+               closeRecordSet();
+       }
+
+       public int getColumnCount() throws Exception{
+               return ColumnCount;
+       }
+
+       public int getRecCount() throws Exception{
+               return recCount;
+       }
+
+       public ArrayList<String> getArrayList() throws Exception{
+               return alData;
+       }
+
+       public ArrayList<String> getArrayColumnNameList() throws Exception{
+               return alColName;
+       }
+       
+       public ArrayList<String> getArrayColumnTypeNameList() throws Exception{
+               return alColTypeName;
+       }
+
+       public ArrayList<Integer> getArrayIsNullableList() throws Exception{
+               return alIsNullable;
+       }
+
+       public void setArrayColumnMaskList(ArrayList<Boolean> _alColMask) throws Exception{
+               alColMask = _alColMask;
+               colMask = (Boolean[])alColMask.toArray(new Boolean[0]);
+       }
+
+       public void setArrayColumnInclList(ArrayList<Boolean> _alColIncl) throws Exception{
+               alColIncl = _alColIncl;
+               colIncl = (Boolean[])alColIncl.toArray(new Boolean[0]);
+       }
+
+       public void setTableName(String _tbName) throws Exception{
+               tbName = _tbName;
+       }
+
+       public ResultSet getResultSet() throws Exception{
+               return rst;
+       }
+
+       public void getRecordToArray() throws Exception{
+               try {
+                       CmnUtils.debugPrint("Start get RecordSet to Array");
+                       while (rst.next()) {
+                               colString = null;
+                               for(int i=0;i<ColumnCount;i++){
+                                       colString = getColString(rst, i + 1, colTypeName[i], isNullable[i], false);
+                                       if (colString != null) {
+                                               alData.add(colString);
+                                       } else {
+                                               alData.add("");
+                                       }
+                               }
+                       }
+                       CmnUtils.debugPrint("End get RecordSet to Array");
+               }
+               catch (SQLException e) {
+                       throw e;
+               }
+               catch (Exception e){
+                       throw e;
+               }
+       }
+       
+       public void getRecordToPrint(PrintWriter _pw, String _splt, boolean _isQuotation, boolean _isMask, int _firstCol, int _lastCol) throws Exception{
+               try {
+                       CmnUtils.debugPrint("Start get Record to Print");
+                       isQuotation = _isQuotation;
+                       isMask = _isMask;
+                       recCount = 0;
+                       String lnSprtr = CmnUtils.getLineSeparator("lnSprtr", System.getProperty("line.separator"));
+                       if(System.getProperty("nullMark")!= null)nullMark = System.getProperty("nullMark");
+                       while (rst.next()) {
+                               colString = null;
+                               for(int i=0;i<ColumnCount;i++){
+                                       if (colIncl[i]){
+                                               colString = getColString(rst, i + 1, colTypeName[i], isNullable[i], colMask[i]);
+
+                                               if (colString != null) {
+                                                       if (i == _firstCol){
+                                                               if(isQuotation){
+                                                                       if (_firstCol == _lastCol){
+                                                                               _pw.print("\"" + colString + "\"" + lnSprtr);
+                                                                       } else {
+                                                                               _pw.print("\"" + colString);
+                                                                       }
+                                                               } else {
+                                                                       if (_firstCol == _lastCol){
+                                                                               _pw.print(colString + lnSprtr);
+                                                                       } else {
+                                                                               _pw.print(colString);
+                                                                       }
+                                                               }
+                                                               
+                                                       } else if (i == _lastCol){
+                                                               if(isQuotation){
+                                                                       _pw.print("\"" + _splt + "\"" + colString + "\"" + lnSprtr);
+                                                               } else {
+                                                                       _pw.print(_splt + colString + lnSprtr);
+                                                               }
+                                                       } else {
+                                                               if(isQuotation){
+                                                                       _pw.print("\"" + _splt + "\"" + colString);
+                                                               } else {
+                                                                       _pw.print(_splt + colString);
+                                                               }
+                                                       }
+                                                       
+                                                       
+
+                                               } else {
+                                                       if (i == _firstCol){
+                                                               if(isQuotation){
+                                                                       if (_firstCol == _lastCol){
+                                                                               _pw.print("\"" + nullMark + "\"" + lnSprtr);
+                                                                       } else {
+                                                                               _pw.print("\"" + nullMark);
+                                                                       }
+                                                               } else {
+                                                                       if (_firstCol == _lastCol){
+                                                                               _pw.print(nullMark + lnSprtr);
+                                                                       } else {
+                                                                               _pw.print(nullMark);
+                                                                       }
+                                                               }
+                                                       } else if (i == _lastCol){
+                                                               if(isQuotation){
+                                                                       _pw.print("\"" + _splt + "\"" + nullMark + "\"" + lnSprtr);
+                                                               } else {
+                                                                       _pw.print(_splt + nullMark + lnSprtr);
+                                                               }
+                                                       } else {
+                                                               if(isQuotation){
+                                                                       _pw.print("\"" + _splt + "\"" + nullMark);
+                                                               } else {
+                                                                       _pw.print(_splt + nullMark);
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               recCount++;
+                       }
+                       CmnUtils.debugPrint("End get Record to Print");
+               }
+               catch (SQLException e) {
+                       throw e;
+               }
+               catch (Exception e){
+                       throw e;
+               }
+       }
+
+       private String getColString(ResultSet _rst, int _rec_cnt, String _colTypeName, Integer _isNullable, Boolean _colMask) throws Exception{
+               String colString = null;
+               java.sql.Timestamp colTimestamp = null;
+               java.sql.Time colTime = null;
+               java.sql.Date colDate = null;
+               BigDecimal colBigDecimal = null;
+               Integer colInt = null;
+               Short colShort = null;
+               Float colFloat = null;
+               Double colDouble = null;
+               byte [] colBytes = null;
+               Blob colBlob = null;
+               Clob colClob = null;
+               ByteArrayOutputStream baos = null;
+               InputStream is = null;
+               boolean isQuotation = CmnUtils.getSystemProperty("quotation", true);
+               boolean isMask = CmnUtils.getSystemProperty("inclMaskCols", false)  || CmnUtils.getSystemProperty("exclMaskCols", false);
+               char hankakuMask = CmnUtils.getSystemProperty("hankakuMask", '*');
+               char zenkakuMask = CmnUtils.getSystemProperty("zenkakuMask", '\81\96');
+               String maskPtn = CmnUtils.getSystemProperty("maskPtn", MASK_PTN[MASK_PTN_ALT]);
+
+               if (CmnUtils.isColString(_colTypeName)) {
+                       colString = _rst.getString(_rec_cnt);
+                       if (colString != null) {
+                               if(isQuotation){
+                                       colString =colString.trim().replaceAll("\0","").replaceAll("\"","\"\"");
+                               } else {
+                                       colString =colString.trim().replaceAll("\0","");
+                               }
+                               if(isMask){
+                                       if(_colMask==true){
+                                               StringBuffer sb = new StringBuffer();
+                                               for(int j=0;j<colString.length();j++){
+                                                       if((maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_ALT]) && 
+                                                                       (j % 2) == 1) || 
+                                                          (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_EDGE]) && 
+                                                                       !(j == 0 || j == colString.length() - 1) ||
+                                                          (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_ALL]))
+                                                          )
+                                                       ){
+                                                                       if(CmnUtils.isHankaku(colString.charAt(j))){
+                                                                               sb.append(hankakuMask);
+                                                                       } else {
+                                                                               sb.append(zenkakuMask);
+                                                                       }
+                                                       } else {
+                                                               sb.append(colString.charAt(j));
+                                                       }
+                                               }
+                                               colString = sb.toString();
+                                       }
+                               }
+                               if(colString.equals(""))colString = " ";
+                       }
+               } else if (CmnUtils.isColDate(_colTypeName)) {
+                       colDate = _rst.getDate(_rec_cnt);
+                       if (colDate != null) {
+                               colString = colDate.toString();
+                       }
+               } else if (CmnUtils.isColTimestamp(_colTypeName)) {
+                       colTimestamp = _rst.getTimestamp(_rec_cnt);
+                       if (colTimestamp != null) {
+                               colString = colTimestamp.toString();
+                       }
+               } else if (CmnUtils.isColTime(_colTypeName)) {
+                       colTime = _rst.getTime(_rec_cnt);
+                       if (colTime != null) {
+                               colString = colTime.toString();
+                       }
+               } else if (CmnUtils.isColBigDecimal(_colTypeName)) {
+                       colBigDecimal = _rst.getBigDecimal(_rec_cnt);
+                       if (colBigDecimal != null) {
+                               colString = colBigDecimal.toString();
+                       }
+               } else if (CmnUtils.isColShort(_colTypeName)) {
+                       colShort = _rst.getShort(_rec_cnt);
+                       if (colShort != null) {
+                               colString = colShort.toString();
+                       }
+               } else if (CmnUtils.isColInt(_colTypeName)) {
+                       colInt = _rst.getInt(_rec_cnt);
+                       if (colInt != null) {
+                               colString = colInt.toString();
+                       }
+               } else if (CmnUtils.isColFloat(_colTypeName)) {
+                       colFloat = _rst.getFloat(_rec_cnt);
+                       if (colFloat != null) {
+                               colString = colFloat.toString();
+                       }
+               } else if (CmnUtils.isColDouble(_colTypeName)) {
+                       colDouble = _rst.getDouble(_rec_cnt);
+                       if (colDouble != null) {
+                               colString = colDouble.toString();
+                       }
+               } else if (CmnUtils.isColBytes(_colTypeName)) {
+                       colBytes = _rst.getBytes(_rec_cnt);
+                       if (colBytes != null) {
+                               colString = CmnUtils.bytesToBase64(colBytes);
+                       }
+               } else if (CmnUtils.isColBlob(_colTypeName)) {
+                       colBlob = _rst.getBlob(_rec_cnt);
+                       if (colBlob != null) {
+                               is = colBlob.getBinaryStream();
+                               baos = new ByteArrayOutputStream();
+                               int len = -1;
+                               colBytes = new byte[8192];
+                               while ((len = is.read(colBytes)) != -1) {
+                                       baos.write(colBytes,0,len);
+                               }
+                               colBytes = baos.toByteArray();
+                               colString = CmnUtils.bytesToBase64(colBytes);
+                               is.close();
+                               baos.close();
+                               is = null;
+                               baos = null;
+                       }
+               } else if (CmnUtils.isColClob(_colTypeName)) {
+                       colClob = _rst.getClob(_rec_cnt);
+                       if (colClob != null) {
+                               colString = CmnUtils.clobToString(colClob);
+                       }
+               } else {
+                       CmnUtils.errorPrint("unmatch column type=" + _colTypeName);
+                       throw new Exception("unmatch column type=" + _colTypeName);
+               }
+               return colString;
+
+       }
+
+       public void disconnect() throws Exception{
+
+               try {
+                       CmnUtils.debugPrint("Start disconnect database");
+                       conn.close();
+                       CmnUtils.debugPrint("End disconnect database");
+                       
+               }
+               catch (SQLException e) {
+                       throw e;
+               }
+               catch (Exception e){
+                       throw e;
+               }
+               finally{
+                       if(conn != null){
+                               conn.close();
+                               conn = null;
+                       }
+               }
+       }
+
+}
+
diff --git a/com/rapide_act/RapideLoader.java b/com/rapide_act/RapideLoader.java
new file mode 100644 (file)
index 0000000..d2b3094
--- /dev/null
@@ -0,0 +1,647 @@
+package com.rapide_act;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.io.PrintWriter;
+import java.util.Date;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.math.BigDecimal;
+
+public class RapideLoader{
+       private String database = null;
+       private String user = null;
+       private String pass = null;
+       private String url = null;
+       private String driver = null;
+       private String sql_table_list = null;
+       private static final int DB_TYPE_ORACLE = 0;
+       private static final int DB_TYPE_SQLSERVER = 1;
+       private static final int DB_TYPE_DB2 = 2;
+       private static final int DB_TYPE_MYSQL = 3;
+       private static final int DB_TYPE_POSTGRESQL = 4;
+       private static final int DB_TYPE_UNKNOWN = -1;
+       private static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"};
+       private static final int MASK_PTN_ALL = 0;
+       private static final int MASK_PTN_ALT = 1;
+       private static final int MASK_PTN_EDGE = 2;
+       private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
+       private String propFile = "RapideLoader.properties";
+       private static String [] arySql_table_list = {
+               "select "
+               + " table_name "
+               + " from user_tables "
+               + " order by table_name",
+               "select "
+               + " name as table_name "
+               + " from sys.tables "
+               + " order by name"
+       };
+
+       public static void main(String args[]){
+               try {
+                       if (args.length > 0){
+                               RapideLoader rapideLoader = new RapideLoader(args[0]);
+                               rapideLoader.load();
+                       } else {
+                               RapideLoader rapideLoader = new RapideLoader(null);
+                               rapideLoader.load();
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       private void getProperties(String _propFile) throws Exception{
+               InputStream is = null;
+               Properties prop = null;
+               try {
+                       prop = new Properties();
+                       is = RapideLoader.class.getClassLoader().getResourceAsStream(_propFile);
+                       prop.load(is);
+                       driver = prop.getProperty(database + "." + "driver");
+                       user = prop.getProperty(database + "." + "user");
+                       pass = prop.getProperty(database + "." + "pass");
+                       url = prop.getProperty(database + "." + "url");
+                       CmnUtils.debugPrint("driver=" + driver);
+                       CmnUtils.debugPrint("user=" + user);
+                       CmnUtils.debugPrint("pass=" + pass);
+                       CmnUtils.debugPrint("url=" + url);
+                       is.close();
+                       is = null;
+               } catch (NullPointerException e) {
+                               throw new Exception("Property File (" + _propFile +") Not Found");
+               } catch (IOException e) {
+                               throw e;
+               }
+               finally{
+                       try {
+                               if (is != null) {
+                                       is.close();
+                                       is = null;
+                               }
+                       } 
+                       catch (IOException e) {
+                               throw e;
+                       }
+               }               
+       }
+
+       RapideLoader(String _database) throws Exception{
+               super();
+               database = _database;
+       }
+
+       private void load() throws Exception{
+               Connection conn                                 = null;
+               PreparedStatement stmt                  = null;
+               PreparedStatement stmt_ins              = null;
+               BufferedReader br                               = null;
+               String sql_load                                 = null;
+               String sql_insert                               = null;
+               int dbType                                              = DB_TYPE_UNKNOWN;
+
+               File fldr                                               = null;
+               ArrayList<String> alData                = null;
+               ArrayList<String> alColName     = null;
+               ArrayList<String> alColTypeName = null;
+               ArrayList<Integer> alIsNullable = null;
+               ArrayList<Boolean> alColMask    = null;
+               ArrayList<Boolean> alColIncl    = null;
+
+               int batchCount                                  = 1000;
+               int tb_count                                    = 0;
+               int tb_col_count                                = 0;
+               int fl_col_count                                = 0;
+
+               String nullMark                                 = "";
+               String strLine                                  = null;
+               String strMltLine                               = null;
+               String tbName                                   = null;
+               String [] flName                                = null;
+               String [] colData                               = null;
+               String [] colName                               = null;
+               String [] colTypeName                   = null;
+               Integer [] isNullable                   = null;
+               Boolean [] colIncl                              = null;
+               String sprtr                                    = CmnUtils.getSeparator("sprtr", "\t");
+               String lnSprtr                                  = CmnUtils.getLineSeparator("lnSprtr", System.getProperty("line.separator"));
+               String inColLnSprtr                     = CmnUtils.getLineSeparator("inColLnSprtr", System.getProperty("line.separator"));
+               String inclTables                               = System.getProperty("inclTables");
+               String exclTables                               = System.getProperty("exclTables");
+               String inclCols                                 = System.getProperty("inclCols");
+               String exclCols                                 = System.getProperty("exclCols");
+               String inclMaskCols                     = System.getProperty("inclMaskCols");
+               String exclMaskCols                     = System.getProperty("exclMaskCols");
+               String [] aryInclTables                 = CmnUtils.getSystemProperty("inclTables");
+               String [] aryExclTables                 = CmnUtils.getSystemProperty("exclTables");
+               String [] aryInclMaskCols               = CmnUtils.getSystemProperty("inclMaskCols");
+               String [] aryExclMaskCols               = CmnUtils.getSystemProperty("exclMaskCols");
+               String [] aryInclCols                   = CmnUtils.getSystemProperty("inclCols");
+               String [] aryExclCols                   = CmnUtils.getSystemProperty("exclCols");
+
+               boolean isLob                                   = false;
+               boolean isContinue                              = false;
+               boolean isQuotation                     = CmnUtils.getSystemProperty("quotation", true);
+               boolean isInclTables                    = CmnUtils.getSystemProperty("inclTables", false);
+               boolean isExclTables                    = CmnUtils.getSystemProperty("exclTables", false);
+               boolean isInclCols                              = CmnUtils.getSystemProperty("inclCols", false);
+               boolean isExclCols                              = CmnUtils.getSystemProperty("exclCols", false);
+               boolean isInclMaskCols                  = CmnUtils.getSystemProperty("inclMaskCols", false);
+               boolean isExclMaskCols                  = CmnUtils.getSystemProperty("exclMaskCols", false);
+               boolean isMask                                  = CmnUtils.getSystemProperty("inclMaskCols", false) || CmnUtils.getSystemProperty("exclMaskCols", false);
+               String defaultFldr                              = "input";
+               String inFldr                                   = System.getProperty("input");
+               char hankakuMask                                = CmnUtils.getSystemProperty("hankakuMask", '*');
+               char zenkakuMask                                = CmnUtils.getSystemProperty("zenkakuMask", '\81\96');
+               String maskPtn                                  = CmnUtils.getSystemProperty("maskPtn", MASK_PTN[MASK_PTN_ALT]);
+               String fileEncoding                     = CmnUtils.getSystemProperty("fileEncoding", System.getProperty("file.encoding"));
+
+               if(System.getProperty("batchCount")!=null){
+                       batchCount = Integer.parseInt(System.getProperty("batchCount"));
+               }
+
+               if(database != null){
+                       if(System.getProperty("propFile") != null){
+                               getProperties(System.getProperty("propFile"));
+                       } else {
+                               getProperties(propFile);
+                       }
+               } else {
+                       user = System.getProperty("user");
+                       pass = System.getProperty("pass");
+                       url = System.getProperty("url");
+                       driver = System.getProperty("driver");
+                       
+               }
+
+               if(user == null){
+                       throw new Exception("user is null");
+               } else if (pass == null){
+                       throw new Exception("pass is null");
+               } else if (url == null){
+                       throw new Exception("url is null");
+               } else if (driver == null){
+                       throw new Exception("driver is null");
+               }
+               
+               for(int i = 0;i<DB_TYPE_NAME.length;i++){
+                       if (url.toUpperCase().contains(DB_TYPE_NAME[i])){
+                               dbType = i;
+                               break;
+                       }
+               }
+               
+               if (dbType != DB_TYPE_UNKNOWN){
+                       if(System.getProperty("sql_table_list") != null){
+                               sql_table_list = System.getProperty("sql_table_list");
+                       } else {
+                               sql_table_list = arySql_table_list[dbType];
+                       }
+               } else {
+                       throw new Exception("dbtype unknown");
+               }
+
+               DataAccessObjects dao = new DataAccessObjects(user, pass, url, driver);
+               try {
+                       conn = dao.connect();
+                       conn.setAutoCommit(false);
+
+                       if(inFldr != null){
+                               fldr = new File(inFldr);
+                       } else {
+                               if (database != null){
+                                       fldr = new File(defaultFldr + "/" + database.toUpperCase());
+                               } else {
+                                       fldr = new File(defaultFldr + "/" + DB_TYPE_NAME[dbType].toUpperCase());
+                               }
+                       }
+                       CmnUtils.infoPrint("-->\91Î\8fÛ\83f\81[\83^\83x\81[\83X='" + database.toUpperCase() + "'");
+                       CmnUtils.infoPrint("-->\93ü\97Í\8c³='" + fldr + "'");
+                       CmnUtils.infoPrint("-->\8bæ\90Ø\82è\95\8e\9a='" + sprtr + "'");
+                       CmnUtils.infoPrint("-->\83o\83b\83`\83J\83E\83\93\83g=" + batchCount);
+                       CmnUtils.infoPrint("-->\88ø\97p\8bå=" + CmnUtils.getYesNo(isQuotation));
+                       if(isInclTables)CmnUtils.infoPrint("-->\91Î\8fÛ\83e\81[\83u\83\8b='" + inclTables.toUpperCase() + "'");
+                       if(isExclTables)CmnUtils.infoPrint("-->\8f\9c\8aO\83e\81[\83u\83\8b='" + exclTables.toUpperCase() + "'");
+                       if(isInclCols)CmnUtils.infoPrint("-->\91Î\8fÛ\83J\83\89\83\80='" + inclCols.toUpperCase() + "'");
+                       if(isExclCols)CmnUtils.infoPrint("-->\8f\9c\8aO\83J\83\89\83\80='" + exclCols.toUpperCase() + "'");
+                       CmnUtils.infoPrint("-->\83}\83X\83L\83\93\83O=" +  CmnUtils.getYesNo(isMask));
+                       if(isMask){
+                               CmnUtils.infoPrint("-->\83}\83X\83N\83L\83\93\83O\83p\83^\81[\83\93=" + maskPtn.toUpperCase());
+                               if(isInclMaskCols)CmnUtils.infoPrint("-->\83}\83X\83N\91Î\8fÛ\83J\83\89\83\80='" + inclMaskCols.toUpperCase() + "'");
+                               if(isExclMaskCols)CmnUtils.infoPrint("-->\83}\83X\83N\8f\9c\8aO\83J\83\89\83\80='" + exclMaskCols.toUpperCase() + "'");
+                               CmnUtils.infoPrint("-->\94¼\8ap\83}\83X\83N\95\8e\9a='" + hankakuMask + "'");
+                               CmnUtils.infoPrint("-->\91S\8ap\83}\83X\83N\95\8e\9a='" + zenkakuMask + "'");
+                       }
+                       CmnUtils.infoPrint("\83f\81[\83^\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82µ\82½\81B");
+
+                       dao.select(sql_table_list);
+                       alData = dao.getArrayList();
+                       tb_count = dao.getColumnCount();
+                       int tb_rec_count = 0;
+                       int fl_rec_count = 0;
+                       int ins_rec_count = 0;
+                       int tb_fl_match_count = 0;
+                       File [] inFiles = fldr.listFiles();
+                       if(inFiles != null) {
+                               for(int k=0;k<inFiles.length;k++){
+                                       flName = CmnUtils.splitDot(inFiles[k].getName());
+                                       tbName = flName[0].toUpperCase();
+                                       StringBuffer sbColumnName = null;
+                                       TABLE_LOOP:
+                                       for(int i=0;i<alData.size();i++){
+                                               if(tbName.equals(alData.get(i))){
+                                                       if(isInclTables && !CmnUtils.isMatch(aryInclTables,tbName.toUpperCase())){
+                                                               CmnUtils.debugPrint("inclTables=" + inclTables);
+                                                               CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(aryInclTables,tbName.toUpperCase()));
+                                                               continue;
+                                                       }
+                                                       if(isExclTables && CmnUtils.isMatch(aryExclTables,tbName.toUpperCase())){
+                                                               CmnUtils.debugPrint("exclTables=" + exclTables);
+                                                               CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(aryExclTables,tbName.toUpperCase()));
+                                                               continue;
+                                                       }
+                                                       br = new BufferedReader(new InputStreamReader(new FileInputStream(fldr + "/" + alData.get(i) + "." + flName[1]), fileEncoding));
+                                                       sql_load = "select * from " + alData.get(i);
+                                                       stmt = dao.prepareSql(sql_load);
+                                                       dao.executeSql(stmt);
+                                                       alColName = dao.getArrayColumnNameList();
+                                                       alColTypeName = dao.getArrayColumnTypeNameList();
+                                                       alIsNullable = dao.getArrayIsNullableList();
+                                                       alColMask = new ArrayList<Boolean>();
+                                                       alColIncl = new ArrayList<Boolean>();
+                                                       colName = (String[])alColName.toArray(new String[0]);
+                                                       colTypeName = (String[])alColTypeName.toArray(new String[0]);
+                                                       isNullable = (Integer[])alIsNullable.toArray(new Integer[0]);
+                                                       tb_col_count = dao.getColumnCount();
+                                                       int [] tb_col_seq = new int[tb_col_count];
+                                                       int [] fl_col_seq = null;
+                                                       dao.closeRecordSet();
+                                                       tb_rec_count = 0;
+                                                       fl_rec_count = 0;
+                                                       ins_rec_count = 0;
+                                                       fl_col_count = 0;
+                                                       tb_fl_match_count = 0;
+                                                       strMltLine = "";
+                                                       isContinue = false;
+                                                       isLob = false;
+                                                       for(int j=0;j<colTypeName.length;j++)if(CmnUtils.isLob(colTypeName[j]))isLob = true;
+                                                       CmnUtils.debugPrint("LOB="+isLob);
+                                                       while((strLine=br.readLine()) != null){
+                                                               if (fl_rec_count == 0){
+                                                                       if(isQuotation){
+                                                                               colData = CmnUtils.split(strLine,"\"" + sprtr + "\"");
+                                                                       } else {
+                                                                               colData = CmnUtils.split(strLine,sprtr);
+                                                                       }
+                                                                       fl_col_count = colData.length;
+                                                                       fl_col_seq = new int[colData.length];
+                                                                       CmnUtils.debugPrint("TableName=" + tbName);
+                                                                       
+                                                                       for(int j=0;j<colData.length;j++){
+                                                                               for(int l=0;l<tb_col_count;l++){
+                                                                                       if(colName[l].equals(colData[j].replaceAll("\"",""))){
+                                                                                               if(isInclCols || isExclCols){
+                                                                                                       if(
+                                                                                                               (isInclCols && 
+                                                                                                                !isExclCols &&
+                                                                                                                CmnUtils.isMatch(aryInclCols, tbName.toUpperCase(), colName[l].toUpperCase())
+                                                                                                               ) ||
+                                                                                                               (isInclCols && 
+                                                                                                                isExclCols &&
+                                                                                                                CmnUtils.isMatch(aryInclCols, tbName.toUpperCase(), colName[l].toUpperCase()) &&
+                                                                                                                !CmnUtils.isMatch(aryExclCols, tbName.toUpperCase(), colName[l].toUpperCase())
+                                                                                                               ) ||
+                                                                                                               (!isInclCols && 
+                                                                                                                isExclCols &&
+                                                                                                                !CmnUtils.isMatch(aryExclCols, tbName.toUpperCase(), colName[l].toUpperCase())
+                                                                                                               )
+                                                                                                       ){
+                                                                                                               CmnUtils.debugPrint("\91Î\8fÛ\83J\83\89\83\80=" + colName[l].toUpperCase());
+                                                                                                               alColIncl.add(true);
+                                                                                                       } else {
+                                                                                                               alColIncl.add(false);
+                                                                                                       }
+                                                                                               } else {
+                                                                                                       alColIncl.add(true);
+                                                                                               }
+                                                                                               break;
+                                                                                       }
+                                                                               }
+                                                                       }
+
+                                                                       colIncl = (Boolean[])alColIncl.toArray(new Boolean[0]);
+
+                                                                       sql_insert = "INSERT INTO " + tbName + "(";
+                                                                       for(int j=0;j<colData.length;j++){
+                                                                               for(int l=0;l<tb_col_count;l++){
+                                                                                       if(colName[l].equals(colData[j].replaceAll("\"",""))){
+                                                                                               if (colIncl[tb_fl_match_count]) {
+                                                                                                       if (ins_rec_count == 0){
+                                                                                                               sql_insert += "\"" + colName[l] + "\"";
+                                                                                                       } else {
+                                                                                                               sql_insert += "," + "\"" + colName[l] + "\"";
+                                                                                                       }
+                                                                                                       tb_col_seq[ins_rec_count]=l;
+                                                                                                       fl_col_seq[ins_rec_count]=j;
+                                                                                                       ins_rec_count++;
+                                                                                               }
+                                                                                               tb_fl_match_count++;
+                                                                                               break;
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                                       if (ins_rec_count > 0){
+                                                                               sql_insert += ") VALUES(";
+                                                                               for(int j=0;j<ins_rec_count;j++){
+                                                                                       if(j==0){
+                                                                                               sql_insert += "?";
+                                                                                       } else {
+                                                                                               sql_insert += ", ?";
+                                                                                       }
+                                                                               }
+                                                                               sql_insert += ")";
+                                                                               stmt_ins = dao.prepareSql(sql_insert);
+                                                                               CmnUtils.debugPrint("************Record Start");
+                                                                               CmnUtils.infoPrinting(String.format("%1$-30s",tbName));
+                                                                       } else {
+                                                                               dao.rollback();
+                                                                               CmnUtils.debugPrint("column count is zero");
+                                                                               if(br != null){
+                                                                                       br.close();
+                                                                                       br=null;
+                                                                               }
+                                                                               if(stmt_ins != null){
+                                                                                       stmt_ins.close();
+                                                                                       stmt_ins=null;
+                                                                               }
+                                                                               break TABLE_LOOP;
+                                                                       }
+                                                               } else {
+                                                                       if(isQuotation){
+                                                                               colData = CmnUtils.split(strLine,"\"" + sprtr + "\"");
+                                                                       } else {
+                                                                               colData = CmnUtils.split(strLine,sprtr);
+                                                                       }
+                                                                       if(colData.length == fl_col_count){
+                                                                               if(!strMltLine.equals("")){
+                                                                                       dao.rollback();
+                                                                                       System.out.println(String.format("%1$10d",tb_rec_count) + " ERROR:column count is unmatch");
+                                                                                       CmnUtils.debugPrint("************Record End");
+                                                                                       if(br != null){
+                                                                                               br.close();
+                                                                                               br=null;
+                                                                                       }
+                                                                                       if(stmt_ins != null){
+                                                                                               stmt_ins.close();
+                                                                                               stmt_ins=null;
+                                                                                       }
+                                                                                       break TABLE_LOOP;
+                                                                               } else {
+                                                                                       isContinue = false;
+                                                                               }
+                                                                       } else {
+                                                                               if (strMltLine.equals("")){
+                                                                                       strMltLine += strLine;
+                                                                                       isContinue = true;
+                                                                               } else {
+                                                                                       strMltLine += inColLnSprtr + strLine;
+                                                                                       if(isQuotation){
+                                                                                               colData = CmnUtils.split(strMltLine,"\"" + sprtr + "\"");
+                                                                                       } else {
+                                                                                               colData = CmnUtils.split(strMltLine,sprtr);
+                                                                                       }
+                                                                                       if(colData.length == fl_col_count){
+                                                                                               isContinue = false;
+                                                                                       } else if(colData.length >fl_col_count){
+                                                                                               dao.rollback();
+                                                                                               CmnUtils.errorPrint(String.format("%1$10d",tb_rec_count) + "column count is unmatch");
+                                                                                               CmnUtils.debugPrint("************Record End");
+                                                                                               if(br != null){
+                                                                                                       br.close();
+                                                                                                       br=null;
+                                                                                               }
+                                                                                               if(stmt_ins != null){
+                                                                                                       stmt_ins.close();
+                                                                                                       stmt_ins=null;
+                                                                                               }
+                                                                                               break TABLE_LOOP;
+                                                                                       } else {
+                                                                                               isContinue = true;
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                                       if(isContinue == false){
+                                                                               for(int j=0;j<ins_rec_count;j++){
+                                                                                       if(j==0){
+                                                                                               if(isQuotation){
+                                                                                                       colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(1,colData[fl_col_seq[j]].length());
+                                                                                               }
+                                                                                       }
+                                                                                       if(j==ins_rec_count-1){
+                                                                                               if(isQuotation){
+                                                                                                       colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(0,colData[fl_col_seq[j]].length()-1);
+                                                                                               }
+                                                                                       }
+                                                                                       if (CmnUtils.isColString(colTypeName[tb_col_seq[j]])){
+                                                                                               if(isMask){
+                                                                                                       if(
+                                                                                                               (isInclMaskCols &&
+                                                                                                                !isExclMaskCols && 
+                                                                                                                CmnUtils.isMatch(aryInclMaskCols,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase())
+                                                                                                               ) ||
+                                                                                                               (isInclMaskCols &&
+                                                                                                                isExclMaskCols && 
+                                                                                                                CmnUtils.isMatch(aryInclMaskCols,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) &&
+                                                                                                                !CmnUtils.isMatch(aryExclMaskCols,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
+                                                                                                               ) ||
+                                                                                                               (!isInclMaskCols &&
+                                                                                                                isExclMaskCols && 
+                                                                                                                !CmnUtils.isMatch(aryExclMaskCols,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
+                                                                                                               )
+                                                                                                       ){
+                                                                                                               StringBuffer sb = new StringBuffer();
+                                                                                                               for(int l=0;l<colData[fl_col_seq[j]].length();l++){
+                                                                                                                       if((maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_ALT]) && 
+                                                                                                                                       (l % 2) == 1) || 
+                                                                                                                          (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_EDGE]) && 
+                                                                                                                                       !(l == 0 || j == colData[fl_col_seq[j]].length() - 1) ||
+                                                                                                                          (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_ALL]))
+                                                                                                                          )
+                                                                                                                       ){
+                                                                                                                               if(CmnUtils.isHankaku(colData[fl_col_seq[j]].charAt(l))){
+                                                                                                                                       sb.append(hankakuMask);
+                                                                                                                               } else {
+                                                                                                                                       sb.append(zenkakuMask);
+                                                                                                                               }
+                                                                                                                       } else {
+                                                                                                                               sb.append(colData[fl_col_seq[j]].charAt(l));
+                                                                                                                       }
+                                                                                                               }
+                                                                                                               colData[fl_col_seq[j]] = sb.toString();
+                                                                                                       }
+                                                                                               }
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       if(isQuotation){
+                                                                                                               stmt_ins.setString(j+1,colData[fl_col_seq[j]].replaceAll("\"\"","\""));
+                                                                                                       } else {
+                                                                                                               stmt_ins.setString(j+1,colData[fl_col_seq[j]]);
+                                                                                                       }
+                                                                                               } else {
+                                                                                                       if(isNullable[j] == 0){
+                                                                                                               stmt_ins.setString(j+1," ");
+                                                                                                       } else {
+                                                                                                               stmt_ins.setString(j+1,null);
+                                                                                                       }
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColDate(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setDate(j+1,java.sql.Date.valueOf(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setDate(j+1,null);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColTime(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setTime(j+1,java.sql.Time.valueOf(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setTime(j+1,null);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColTimestamp(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setTimestamp(j+1,java.sql.Timestamp.valueOf(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setTimestamp(j+1,null);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColBigDecimal(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setBigDecimal(j+1,new BigDecimal(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setNull(j+1,java.sql.Types.DECIMAL);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColShort(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setShort(j+1,Short.parseShort(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setNull(j+1,java.sql.Types.SMALLINT);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColInt(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setInt(j+1,Integer.parseInt(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setNull(j+1,java.sql.Types.INTEGER);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColFloat(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setFloat(j+1,Float.parseFloat(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setNull(j+1,java.sql.Types.REAL);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColDouble(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setDouble(j+1,Double.parseDouble(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setNull(j+1,java.sql.Types.FLOAT);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColBytes(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setBytes(j+1,CmnUtils.base64ToBytes(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setBytes(j+1,null);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColBlob(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setBytes(j+1,CmnUtils.base64ToBytes(colData[fl_col_seq[j]]));
+                                                                                               } else {
+                                                                                                       stmt_ins.setBlob(j+1,null,0);
+                                                                                               }
+                                                                                       } else if (CmnUtils.isColClob(colTypeName[tb_col_seq[j]])){
+                                                                                               if (!colData[fl_col_seq[j]].equals("")){
+                                                                                                       stmt_ins.setString(j+1,colData[fl_col_seq[j]]);
+                                                                                               } else {
+                                                                                                       stmt_ins.setClob(j+1,null,0);
+                                                                                               }
+                                                                                       } else {
+                                                                                               CmnUtils.errorPrint("unmatch column type=" + colTypeName[tb_col_seq[j]]);
+                                                                                               break TABLE_LOOP;
+                                                                                       }
+                                                                               }
+                                                                               if(isLob){
+                                                                                       stmt_ins.executeUpdate();
+                                                                               } else {
+                                                                                       stmt_ins.addBatch();
+                                                                               }
+                                                                               strMltLine = "";
+                                                                               tb_rec_count++;
+                                                                       }
+                                                               }
+                                                               fl_rec_count++;
+                                                               if (fl_rec_count % batchCount == 0){
+                                                                       if(!isLob)stmt_ins.executeBatch();
+                                                                       CmnUtils.debugPrint("insert record=" + fl_rec_count);
+                                                               }
+                                                       }
+                                                       if(!isLob)stmt_ins.executeBatch();
+                                                       dao.commit();
+                                                       System.out.println(String.format("%1$10d",tb_rec_count) + " rows imported");
+                                                       CmnUtils.debugPrint("************Record End");
+                                                       if(br != null){
+                                                               br.close();
+                                                               br=null;
+                                                       }
+                                                       if(stmt_ins != null){
+                                                               stmt_ins.close();
+                                                               stmt_ins=null;
+                                                       }
+                                                       
+                                               }
+                                       }
+                               }
+                       } else {
+                               CmnUtils.errorPrint("Folder Not Found(" + fldr + ")");
+                               throw new Exception("Folder Not Found(" + fldr + ")");
+                       }
+
+                       dao.disconnect();
+
+               } catch (Exception e) {
+                       dao.rollback();
+                       throw e;
+               } finally{
+                       if(stmt != null){
+                               stmt.close();
+                               stmt=null;
+                       }
+                       if(stmt_ins != null){
+                               stmt_ins.close();
+                               stmt_ins=null;
+                       }
+                       if(br!=null){
+                               br.close();
+                               br=null;
+                       }
+               }
+               CmnUtils.infoPrint("\83f\81[\83^\83\8d\81[\83h\82ð\8fI\97¹\82µ\82Ü\82µ\82½\81B");
+       }
+       
+
+}
+
diff --git a/com/rapide_act/RapideUnloader.java b/com/rapide_act/RapideUnloader.java
new file mode 100644 (file)
index 0000000..a825f07
--- /dev/null
@@ -0,0 +1,467 @@
+package com.rapide_act;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+
+public class RapideUnloader{
+       
+       private String database = null;
+       private String driver = null;
+       private String user = null;
+       private String pass = null;
+       private String url = null;
+       private String sql_table_list;
+       private static final int DB_TYPE_ORACLE = 0;
+       private static final int DB_TYPE_SQLSERVER = 1;
+       private static final int DB_TYPE_DB2 = 2;
+       private static final int DB_TYPE_MYSQL = 3;
+       private static final int DB_TYPE_POSTGRESQL = 4;
+       private static final int DB_TYPE_UNKNOWN = -1;
+       private static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"};
+       private static final int MASK_PTN_ALL = 0;
+       private static final int MASK_PTN_ALT = 1;
+       private static final int MASK_PTN_EDGE = 2;
+       private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
+       private String propFile = "RapideLoader.properties";
+
+       private static String [] arySql_table_list = {
+               "select "
+               + "a.table_name,"
+               + "d.column_name "
+               + " from user_tables a,"
+               + " (select b.table_name, "
+               + "   c.column_name, "
+               + "   c.position "
+               + "  from user_constraints b, "
+               + "       user_cons_columns c "
+               + "  where b.CONSTRAINT_TYPE = 'P' and "
+               + "        b.TABLE_NAME = c.TABLE_NAME and "
+               + "        b.CONSTRAINT_NAME = c.CONSTRAINT_NAME "
+               + "  ) d "
+               + "where a.table_name = d.table_name(+) "
+               + "order by a.table_name, d.position",
+               "SELECT "
+               + " A.name AS table_name, "
+               + " D.name AS col_name "
+               + "FROM sys.tables AS A "
+               + "LEFT OUTER JOIN sys.key_constraints AS B "
+               + "ON A.object_id = B.parent_object_id "
+               + " AND B.type = 'PK' "
+               + "LEFT OUTER JOIN sys.index_columns AS C "
+               + "ON B.parent_object_id = C.object_id "
+               + " AND B.unique_index_id = C.index_id "
+               + "LEFT OUTER JOIN sys.columns AS D "
+               + "ON C.object_id = D.object_id "
+               + " AND C.column_id = D.column_id "
+               + "order by A.name,C.key_ordinal"
+       };
+
+       public static void main(String args[]){
+               try {
+                       if (args.length > 0){
+                               RapideUnloader rapideUnloader = new RapideUnloader(args[0]);
+                               rapideUnloader.unload();
+                       } else {
+                               RapideUnloader rapideUnloader = new RapideUnloader(null);
+                               rapideUnloader.unload();
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       RapideUnloader(String _database) throws Exception{
+               super();
+               database = _database;
+
+       }
+
+       private void getProperties(String _propFile) throws Exception{
+               InputStream is = null;
+               Properties prop = null;
+               try {
+                       prop = new Properties();
+                       is = RapideUnloader.class.getClassLoader().getResourceAsStream(_propFile);
+                       prop.load(is);
+                       driver = prop.getProperty(database + "." + "driver");
+                       user = prop.getProperty(database + "." + "user");
+                       pass = prop.getProperty(database + "." + "pass");
+                       url = prop.getProperty(database + "." + "url");
+                       CmnUtils.debugPrint("user=" + user);
+                       CmnUtils.debugPrint("pass=" + pass);
+                       CmnUtils.debugPrint("url=" + url);
+                       CmnUtils.debugPrint("driver=" + driver);
+                       is.close();
+                       is = null;
+               } catch (NullPointerException e) {
+                               throw new Exception("Property File (" + _propFile +") Not Found");
+               } catch (IOException e) {
+                               throw e;
+               }
+               finally{
+                       try {
+                               if (is != null) {
+                                       is.close();
+                                       is = null;
+                               }
+                       } 
+                       catch (IOException e) {
+                               throw e;
+                       }
+               }               
+       }
+
+       private void unload() throws Exception{
+               Connection conn                                 = null;
+               PreparedStatement stmt                  = null;
+               ResultSet rst                                   = null;
+               String sql_unload                               = null;
+               String sql_insert                               = null;
+               String order_columns                    = "";
+               int orders                                              = 0;
+               int dbType                                              = DB_TYPE_UNKNOWN;
+
+               PrintWriter pw                                  = null;
+               File fldr                                               = null;
+               ArrayList<String>  alColName    = null;
+               ArrayList<String>  alColTypeName = null;
+               ArrayList<Integer> alIsNullable = null;
+               ArrayList<Boolean> alColMask    = null;
+               ArrayList<Boolean> alColIncl    = null;
+               ArrayList<String>  alData               = null;
+               int tb_count                                    = 0;
+               int tb_col_count                                = 0;
+
+               boolean isOrder                                 = CmnUtils.getSystemProperty("order", false);
+               boolean isQuotation                     = CmnUtils.getSystemProperty("quotation", true);
+               boolean isInclTables                    = CmnUtils.getSystemProperty("inclTables", false);
+               boolean isExclTables                    = CmnUtils.getSystemProperty("exclTables", false);
+               boolean isMask                                  = CmnUtils.getSystemProperty("inclMaskCols", false) || CmnUtils.getSystemProperty("exclMaskCols", false);
+               boolean isInclMaskCols                  = CmnUtils.getSystemProperty("inclMaskCols", false);
+               boolean isExclMaskCols                  = CmnUtils.getSystemProperty("exclMaskCols", false);
+               boolean isInclCols                              = CmnUtils.getSystemProperty("inclCols", false);
+               boolean isExclCols                              = CmnUtils.getSystemProperty("exclCols", false);
+               String sprtr                                    = CmnUtils.getSeparator("sprtr", "\t");
+               String lnSprtr                                  = CmnUtils.getLineSeparator("lnSprtr", System.getProperty("line.separator"));
+               String inColSprtr                               = CmnUtils.getLineSeparator("inColSprtr", System.getProperty("line.separator"));
+               String defaultFldr                              = "output";
+               String outFldr                                  = System.getProperty("output");
+               String inclTables                               = System.getProperty("inclTables");
+               String exclTables                               = System.getProperty("exclTables");
+               String inclCols                                 = System.getProperty("inclCols");
+               String exclCols                                 = System.getProperty("exclCols");
+               String inclMaskCols                     = System.getProperty("inclMaskCols");
+               String exclMaskCols                     = System.getProperty("exclMaskCols");
+               String [] aryInclTables                 = CmnUtils.getSystemProperty("inclTables");
+               String [] aryExclTables                 = CmnUtils.getSystemProperty("exclTables");
+               String [] aryInclMaskCols               = CmnUtils.getSystemProperty("inclMaskCols");
+               String [] aryExclMaskCols               = CmnUtils.getSystemProperty("exclMaskCols");
+               String [] aryInclCols                   = CmnUtils.getSystemProperty("inclCols");
+               String [] aryExclCols                   = CmnUtils.getSystemProperty("exclCols");
+               char hankakuMask                                = CmnUtils.getSystemProperty("hankakuMask", '*');
+               char zenkakuMask                                = CmnUtils.getSystemProperty("zenkakuMask", '\81\96');
+               String maskPtn                                  = CmnUtils.getSystemProperty("maskPtn", "alt");
+               String fileEncoding                     = CmnUtils.getSystemProperty("fileEncoding", System.getProperty("file.encoding"));
+
+               if(database != null){
+                       if(System.getProperty("propFile") != null){
+                               getProperties(System.getProperty("propFile"));
+                       } else {
+                               getProperties(propFile);
+                       }
+               } else {
+                       user = System.getProperty("user");
+                       pass = System.getProperty("pass");
+                       url = System.getProperty("url");
+                       driver = System.getProperty("driver");
+                       
+               }
+
+               if(user == null){
+                       throw new Exception("user is null");
+               } else if (pass == null){
+                       throw new Exception("pass is null");
+               } else if (url == null){
+                       throw new Exception("url is null");
+               } else if (driver == null){
+                       throw new Exception("driver is null");
+               }
+               
+               for(int i = 0;i<DB_TYPE_NAME.length;i++){
+                       if (url.toUpperCase().contains(DB_TYPE_NAME[i])){
+                               dbType = i;
+                               break;
+                       }
+               }
+               
+               if (dbType != DB_TYPE_UNKNOWN){
+                       if(System.getProperty("sql_table_list") != null){
+                               sql_table_list = System.getProperty("sql_table_list");
+                       } else {
+                               sql_table_list = arySql_table_list[dbType];
+                       }
+               } else {
+                       throw new Exception("dbtype unknown");
+               }
+
+               DataAccessObjects dao = new DataAccessObjects(user, pass, url, driver);
+               try {
+                       conn = dao.connect();
+                       
+                       if(outFldr != null){
+                               fldr = new File(outFldr);
+                       } else {
+                               if (database != null){
+                                       fldr = new File(defaultFldr + "/" + database.toUpperCase() + "_" + CmnUtils.getYmdhm());
+                               } else {
+                                       fldr = new File(defaultFldr + "/" + DB_TYPE_NAME[dbType].toUpperCase() + "_" + CmnUtils.getYmdhm());
+                               }
+                               fldr.mkdir();
+                       }
+                       
+                       CmnUtils.infoPrint("-->\91Î\8fÛ\83f\81[\83^\83x\81[\83X='" + database.toUpperCase() + "'");
+                       CmnUtils.infoPrint("-->\8fo\97Í\90æ='" + fldr + "'");
+                       CmnUtils.infoPrint("-->\8bæ\90Ø\82è\95\8e\9a='" + sprtr + "'");
+                       CmnUtils.infoPrint("-->\83\\81[\83g=" + CmnUtils.getYesNo(isOrder));
+                       CmnUtils.infoPrint("-->\88ø\97p\8bå=" + CmnUtils.getYesNo(isQuotation));
+                       if(isInclTables)CmnUtils.infoPrint("-->\91Î\8fÛ\83e\81[\83u\83\8b='" + inclTables.toUpperCase() + "'");
+                       if(isExclTables)CmnUtils.infoPrint("-->\8f\9c\8aO\83e\81[\83u\83\8b='" + exclTables.toUpperCase() + "'");
+                       if(isInclCols)CmnUtils.infoPrint("-->\91Î\8fÛ\83J\83\89\83\80='" + inclCols.toUpperCase() + "'");
+                       if(isExclCols)CmnUtils.infoPrint("-->\8f\9c\8aO\83J\83\89\83\80='" + exclCols.toUpperCase() + "'");
+                       CmnUtils.infoPrint("-->\83}\83X\83L\83\93\83O=" + CmnUtils.getYesNo(isMask));
+                       if(isMask){
+                               CmnUtils.infoPrint("-->\83}\83X\83N\83L\83\93\83O\83p\83^\81[\83\93=" + maskPtn.toUpperCase());
+                               if(isInclMaskCols)CmnUtils.infoPrint("-->\83}\83X\83N\91Î\8fÛ\83J\83\89\83\80='" + inclMaskCols.toUpperCase() + "'");
+                               if(isExclMaskCols)CmnUtils.infoPrint("-->\83}\83X\83N\8f\9c\8aO\83J\83\89\83\80='" + exclMaskCols.toUpperCase() + "'");
+                               CmnUtils.infoPrint("-->\94¼\8ap\83}\83X\83N\95\8e\9a='" + hankakuMask + "'");
+                               CmnUtils.infoPrint("-->\91S\8ap\83}\83X\83N\95\8e\9a='" + zenkakuMask + "'");
+                       }
+                       CmnUtils.infoPrint("\83f\81[\83^\83A\83\93\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82µ\82½\81B");
+
+                       dao.select(sql_table_list);
+                       alData = dao.getArrayList();
+                       tb_count = dao.getColumnCount();
+                       orders = 0;
+                       order_columns = "";
+                       CmnUtils.debugPrint("tables=" + alData.size());
+                       for(int i=0;i<alData.size();i++){
+                               if ((i+1) % tb_count == 1){
+                                       if ((i + 2 <alData.size()) && (!alData.get(i).equals(alData.get(i+2))) || (i + 2 == alData.size())) {
+                                               if(isInclTables && !CmnUtils.isMatch(aryInclTables,alData.get(i).toUpperCase())){
+                                                       CmnUtils.debugPrint("inclTables=" + inclTables);
+                                                       CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(aryInclTables,alData.get(i).toUpperCase()));
+                                                       orders = 0;
+                                                       order_columns = "";
+                                                       continue;
+                                               }
+                                               if(isExclTables && CmnUtils.isMatch(aryExclTables,alData.get(i).toUpperCase())){
+                                                       CmnUtils.debugPrint("exclTables=" + exclTables);
+                                                       CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(aryExclTables,alData.get(i).toUpperCase()));
+                                                       orders = 0;
+                                                       order_columns = "";
+                                                       continue;
+                                               }
+                                               if (!alData.get(i+1).equals("")){
+                                                       if(isOrder){
+                                                               if (orders == 0){
+                                                                       if (!alData.get(i+1).equals(""))order_columns = alData.get(i+1);
+                                                               } else {
+                                                                       order_columns += "," + alData.get(i+1);
+                                                               }
+                                                               orders++;
+                                                       }
+                                               }                                                       
+                                               if(isOrder){
+                                                       if(!order_columns.equals("")){
+                                                               sql_unload = "select * from " + alData.get(i) + " order by " + order_columns;
+                                                       } else {
+                                                               sql_unload = "select * from " + alData.get(i);
+                                                       }
+                                               } else {
+                                                       sql_unload = "select * from " + alData.get(i);
+                                               }
+                                               CmnUtils.debugPrint("i=" + i);
+                                               CmnUtils.debugPrint(sql_unload);
+                                               stmt = dao.prepareSql(sql_unload);
+                                               dao.executeSql(stmt);
+                                               alColName = dao.getArrayColumnNameList();
+                                               alColTypeName = dao.getArrayColumnTypeNameList();
+                                               alColMask = new ArrayList<Boolean>();
+                                               alColIncl = new ArrayList<Boolean>();
+                                               tb_col_count = dao.getColumnCount();
+                                               for(int j=0;j<alColName.size();j++){
+                                                       if(CmnUtils.isColString(alColTypeName.get(j))){
+                                                               if(isMask){
+                                                                       if(
+                                                                               (isInclMaskCols && 
+                                                                                !isExclMaskCols &&
+                                                                                CmnUtils.isMatch(aryInclMaskCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                               ) ||
+                                                                               (isInclMaskCols && 
+                                                                                isExclMaskCols &&
+                                                                                CmnUtils.isMatch(aryInclMaskCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) &&
+                                                                                !CmnUtils.isMatch(aryExclMaskCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                               ) ||
+                                                                               (!isInclMaskCols && 
+                                                                                isExclMaskCols &&
+                                                                                !CmnUtils.isMatch(aryExclMaskCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                               ) 
+                                                                       ){
+                                                                               CmnUtils.debugPrint("\83}\83X\83N\91Î\8fÛ\83J\83\89\83\80" + alColName.get(j).toUpperCase());
+                                                                               alColMask.add(true);
+                                                                       } else {
+                                                                               alColMask.add(false);
+                                                                       }
+                                                               } else {
+                                                                       alColMask.add(false);
+                                                               }
+                                                       } else {
+                                                               alColMask.add(false);
+                                                       }
+                                                       if(isInclCols || isExclCols){
+                                                               if(
+                                                                       (isInclCols && 
+                                                                        !isExclCols &&
+                                                                        CmnUtils.isMatch(aryInclCols,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase())
+                                                                       ) ||
+                                                                       (isInclCols && 
+                                                                        isExclCols &&
+                                                                        CmnUtils.isMatch(aryInclCols,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase()) &&
+                                                                        !CmnUtils.isMatch(aryExclCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                       ) ||
+                                                                       (!isInclCols && 
+                                                                        isExclCols &&
+                                                                        !CmnUtils.isMatch(aryExclCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+                                                                       )
+                                                               ){
+                                                                       CmnUtils.debugPrint("\91Î\8fÛ\83J\83\89\83\80=" + alColName.get(j).toUpperCase());
+                                                                       alColIncl.add(true);
+                                                               } else {
+                                                                       alColIncl.add(false);
+                                                               }
+                                                       } else {
+                                                               alColIncl.add(true);
+                                                       }
+                                               }
+                                               Boolean [] colIncl = (Boolean[])alColIncl.toArray(new Boolean[0]);
+                                               int firstCol;
+                                               int lastCol;
+                                               for(firstCol=0;firstCol<colIncl.length-1;firstCol++){
+                                                       if(colIncl[firstCol]){
+                                                               break;
+                                                       }
+                                               }
+                                               for(lastCol=colIncl.length-1;lastCol >= 0;lastCol--){
+                                                       if(colIncl[lastCol]){
+                                                               break;
+                                                       }
+                                               }
+                                               CmnUtils.debugPrint("firstCol=" + firstCol);
+                                               CmnUtils.debugPrint("lastCol=" + lastCol);
+                                               
+                                               dao.setTableName(alData.get(i));
+                                               dao.setArrayColumnInclList(alColIncl);
+                                               dao.setArrayColumnMaskList(alColMask);
+                                               
+                                               if (lastCol >= 0){
+                                                       pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fldr + "/" + alData.get(i) + ".csv"), fileEncoding)));
+                                                       CmnUtils.infoPrinting(String.format("%1$-30s",alData.get(i)));
+
+                                                       for(int j=0;j<alColName.size();j++){
+                                                               if(j==firstCol){
+                                                                       if(isQuotation){
+                                                                               pw.print("\"" + alColName.get(j));
+                                                                       } else {
+                                                                               pw.print(alColName.get(j));
+                                                                       }
+                                                               } else {
+                                                                       if(colIncl[j])pw.print(alColName.get(j));
+                                                               }
+                                                               if (firstCol == lastCol){
+                                                                       if(isQuotation){
+                                                                               pw.print("\"" + lnSprtr);
+                                                                       } else {
+                                                                               pw.print("" + lnSprtr);
+                                                                       }
+                                                               } else {
+                                                                       if (j==lastCol){
+                                                                               if(isQuotation){
+                                                                                       pw.print("\"" + lnSprtr);
+                                                                               } else {
+                                                                                       pw.print("" + lnSprtr);
+                                                                               }
+                                                                       } else {
+                                                                               if(colIncl[j]){
+                                                                                       if(isQuotation){
+                                                                                               pw.print("\"" + sprtr + "\"");
+                                                                                       } else {
+                                                                                               pw.print(sprtr);
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                                       dao.getRecordToPrint(pw,sprtr,isQuotation,isMask,firstCol,lastCol);
+                                                       dao.closeRecordSet();
+                                                       pw.close();
+                                                       pw = null;
+                                                       System.out.println(String.format("%1$10d",dao.getRecCount()) + " rows exported");
+                                               }
+                                               orders = 0;
+                                               order_columns = "";
+                                       } else {
+                                               if (!alData.get(i+1).equals("")){
+                                                       if(isOrder){
+                                                               if (orders == 0){
+                                                                       if (!alData.get(i+1).equals(""))order_columns = alData.get(i+1);
+                                                               } else {
+                                                                       order_columns += "," + alData.get(i+1);
+                                                               }
+                                                               orders++;
+                                                       }
+                                               }
+                                               continue;
+                                       }
+                               } else {
+                               }
+                       }
+
+                       dao.disconnect();
+
+               } catch (Exception e) {                 
+                       throw e;
+               } finally{
+                       if(pw!=null){
+                               pw.close();
+                               pw=null;
+                       }
+               }
+               CmnUtils.infoPrint("\83f\81[\83^\83A\83\93\83\8d\81[\83h\82ð\8fI\97¹\82µ\82Ü\82µ\82½\81B");
+       }
+
+
+}
+