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 boolean isInclMaskCols = false;
- private boolean isExclMaskCols = false;
- private String inclMaskCols = null;
- private String exclMaskCols = null;
private String tbName = null;
- private String nullMark = "";
- private String lnSprtr = System.getProperty("line.separator");
- private String delimiter = "\t";
- private char singleByteChr = '*';
- private char doubleByteChr = '\81\96';
- private String maskPtn = "ALT";
- 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 static final int USER = 0;
- private static final int PASS = 1;
- private static final int URL = 2;
- private static final int DRIVER = 3;
- private static final int OUTPUT = 4;
- private static final int INPUT = 5;
- private static final int LINESEP = 6;
- private static final int INLINESEP = 7;
- private static final int FILENCODE = 8;
- private static final int NULLMARK = 9;
- private static final int DELIMITER = 10;
- private static final int TBLSQL = 11;
- private static final int TBLKEYSQL = 12;
- private static final int ORDER = 13;
- private static final int QUOTATION = 14;
- private static final int BATCOUNT = 15;
- private static final int INCLTAB = 16;
- private static final int EXCLTAB = 17;
- private static final int INCLCOL = 18;
- private static final int EXCLCOL = 19;
- private static final int INCLCOLMASK = 20;
- private static final int EXCLCOLMASK = 21;
- private static final int SBYTEMASKCHR = 22;
- private static final int DBYTEMASKCHR = 23;
- private static final int MASKPTN = 24;
- private static final int PROPFILE = 25;
- private static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm",
- "dm","ts","tks","od","qt","bc","it","et","ic","ec",
- "icm","ecm","smc","dmc","mp","pf"};
- private static final int KEYS = 26;
- private String [] prop_val = null;
+ private int recCount = 0;
+ private CmnProperty cp = null;
+
DataAccessObjects(String _user, String _pass, String _url, String _driver){
user = _user;
pass = _pass;
driver = _driver;
}
+ DataAccessObjects(CmnProperty _cp){
+ cp = _cp;
+ user = cp.user;
+ pass = cp.pass;
+ url = cp.url;
+ driver = cp.driver;
+ }
+
public Connection connect() throws Exception{
try {
tbName = _tbName;
}
- public void setPropVal(String[] _prop_val) throws Exception{
- prop_val = _prop_val;
- if(!CmnUtils.isEmpty(prop_val[LINESEP]))lnSprtr = CmnUtils.getLineSeparator(prop_val[LINESEP]);
- if(!CmnUtils.isEmpty(prop_val[NULLMARK]))nullMark = prop_val[NULLMARK];
- if(!CmnUtils.isEmpty(prop_val[QUOTATION]) && prop_val[QUOTATION].toUpperCase().equals("N"))isQuotation = false;
- if(!CmnUtils.isEmpty(prop_val[INCLCOLMASK]))isInclMaskCols = true;
- if(!CmnUtils.isEmpty(prop_val[EXCLCOLMASK]))isExclMaskCols = true;
- if(isInclMaskCols || isExclMaskCols)isMask = true;
- if(!CmnUtils.isEmpty(prop_val[SBYTEMASKCHR]))singleByteChr = prop_val[SBYTEMASKCHR].charAt(0);
- if(!CmnUtils.isEmpty(prop_val[DBYTEMASKCHR]))doubleByteChr = prop_val[DBYTEMASKCHR].charAt(0);
- if(!CmnUtils.isEmpty(prop_val[MASKPTN]))maskPtn = prop_val[MASKPTN];
- if(!CmnUtils.isEmpty(prop_val[DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[DELIMITER]);
- }
-
public ResultSet getResultSet() throws Exception{
return rst;
}
if (colString != null) {
if (i == _firstCol){
- if(isQuotation){
+ if(cp.isQuotation){
if (_firstCol == _lastCol){
- _pw.print("\"" + colString + "\"" + lnSprtr);
+ _pw.print("\"" + colString + "\"" + cp.lineSeparator);
} else {
_pw.print("\"" + colString);
}
} else {
if (_firstCol == _lastCol){
- _pw.print(colString + lnSprtr);
+ _pw.print(colString + cp.lineSeparator);
} else {
_pw.print(colString);
}
}
} else if (i == _lastCol){
- if(isQuotation){
- _pw.print("\"" + delimiter + "\"" + colString + "\"" + lnSprtr);
+ if(cp.isQuotation){
+ _pw.print("\"" + cp.delimiter + "\"" + colString + "\"" + cp.lineSeparator);
} else {
- _pw.print(delimiter + colString + lnSprtr);
+ _pw.print(cp.delimiter + colString + cp.lineSeparator);
}
} else {
- if(isQuotation){
- _pw.print("\"" + delimiter + "\"" + colString);
+ if(cp.isQuotation){
+ _pw.print("\"" + cp.delimiter + "\"" + colString);
} else {
- _pw.print(delimiter + colString);
+ _pw.print(cp.delimiter + colString);
}
}
} else {
if (i == _firstCol){
- if(isQuotation){
+ if(cp.isQuotation){
if (_firstCol == _lastCol){
- _pw.print("\"" + nullMark + "\"" + lnSprtr);
+ _pw.print("\"" + cp.nullMark + "\"" + cp.lineSeparator);
} else {
- _pw.print("\"" + nullMark);
+ _pw.print("\"" + cp.nullMark);
}
} else {
if (_firstCol == _lastCol){
- _pw.print(nullMark + lnSprtr);
+ _pw.print(cp.nullMark + cp.lineSeparator);
} else {
- _pw.print(nullMark);
+ _pw.print(cp.nullMark);
}
}
} else if (i == _lastCol){
- if(isQuotation){
- _pw.print("\"" + delimiter + "\"" + nullMark + "\"" + lnSprtr);
+ if(cp.isQuotation){
+ _pw.print("\"" + cp.delimiter + "\"" + cp.nullMark + "\"" + cp.lineSeparator);
} else {
- _pw.print(delimiter + nullMark + lnSprtr);
+ _pw.print(cp.delimiter + cp.nullMark + cp.lineSeparator);
}
} else {
- if(isQuotation){
- _pw.print("\"" + delimiter + "\"" + nullMark);
+ if(cp.isQuotation){
+ _pw.print("\"" + cp.delimiter + "\"" + cp.nullMark);
} else {
- _pw.print(delimiter + nullMark);
+ _pw.print(cp.delimiter + cp.nullMark);
}
}
}
if (CmnUtils.isColString(_colTypeName)) {
colString = _rst.getString(_rec_cnt);
if (colString != null) {
- if(isQuotation){
+ if(cp.isQuotation){
colString =colString.trim().replaceAll("\0","").replaceAll("\"","\"\"");
} else {
colString =colString.trim().replaceAll("\0","");
}
- if(isMask){
+ if(cp.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]) &&
+ if((cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALT]) &&
(j % 2) == 1) ||
- (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_EDGE]) &&
+ (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_EDGE]) &&
!(j == 0 || j == colString.length() - 1) ||
- (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_ALL]))
+ (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALL]))
)
){
if(CmnUtils.isHankaku(colString.charAt(j))){
- sb.append(singleByteChr);
+ sb.append(cp.singleByteMaskChar);
} else {
- sb.append(doubleByteChr);
+ sb.append(cp.doubleByteMaskChar);
}
} else {
sb.append(colString.charAt(j));
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 tkSql;
- 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 int MASK_PTN_ALL = 0;
- private static final int MASK_PTN_ALT = 1;
- private static final int MASK_PTN_EDGE = 2;
- private static final int D_USER = 0;
- private static final int D_PASS = 1;
- private static final int D_URL = 2;
- private static final int D_DRIVER = 3;
- private static final int D_OUTPUT = 4;
- private static final int D_INPUT = 5;
- private static final int D_LINESEP = 6;
- private static final int D_INLINESEP = 7;
- private static final int D_FILENCODE = 8;
- private static final int D_NULLMARK = 9;
- private static final int D_DELIMITER = 10;
- private static final int D_TBLSQL = 11;
- private static final int D_TBLKEYSQL = 12;
- private static final int D_ORDER = 13;
- private static final int D_QUOTATION = 14;
- private static final int D_BATCOUNT = 15;
- private static final int D_INCLTAB = 16;
- private static final int D_EXCLTAB = 17;
- private static final int D_INCLCOL = 18;
- private static final int D_EXCLCOL = 19;
- private static final int D_INCLCOLMASK = 20;
- private static final int D_EXCLCOLMASK = 21;
- private static final int D_SBYTEMASKCHR = 22;
- private static final int D_DBYTEMASKCHR = 23;
- private static final int D_MASKPTN = 24;
- private static final int D_PROPFILE = 25;
- private static final int KEYS = 26;
- private static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"};
- private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
- private static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm",
- "dm","ts","tks","od","qt","bc","it","et","ic","ec",
- "icm","ecm","smc","dmc","mp","pf"};
- private static final String DEFAULT_FOLDER = "output";
- private static final String DEFAULT_PROP_FILE = "RapideLoader.properties";
-
- private String nullMark = "";
- private boolean isOrder = false;
- private boolean isQuotation = true;
- private boolean isInclTables = false;
- private boolean isExclTables = false;
- private boolean isInclCols = false;
- private boolean isExclCols = false;
- private boolean isMask = false;
- private boolean isInclColsMask = false;
- private boolean isExclColsMask = false;
- private String delimiter = "\t";
- private String lineSeparator = System.getProperty("line.separator");
- private String inColLineSeparator = System.getProperty("line.separator");
- private String outFolder = null;
- private String inFolder = null;
- private String inclTables = null;
- private String exclTables = null;
- private String inclCols = null;
- private String exclCols = null;
- private String inclMaskCols = null;
- private String exclMaskCols = null;
- private String [] inclTablesArray = null;
- private String [] exclTablesArray = null;
- private String [] inclColsArray = null;
- private String [] exclColsArray = null;
- private String [] inclColsMaskArray = null;
- private String [] exclColsMaskArray = null;
- private char singleByteMaskChar = '*';
- private char doubleByteMaskChar = '\u25A0';
- private String maskPattern = "ALT";
- private String fileEncoding = System.getProperty("file.encoding");
-
- private String [] prop_val = new String[KEYS];
-
-
- private static String [] tkSqlArray = {
- "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 {
}
}
- RapideUnloader(String _database) throws Exception{
+ RapideUnloader(String _database) {
super();
database = _database;
}
- private void getProperties(String _propFile) throws Exception{
- BufferedReader br = null;
- Properties prop = null;
- try {
- prop = new Properties();
- br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(_propFile), "UTF-8"));
- prop.load(br);
- for(int i=0;i<KEYS;i++){
- prop_val[i] = prop.getProperty(database + "." +PROP_KEY[i]);
- }
- br.close();
- br = null;
- } catch (NullPointerException e) {
- throw new Exception("Property File (" + _propFile +") Not Found");
- } catch (IOException e) {
- throw e;
- }
- finally{
- try {
- if (br != null) {
- br.close();
- br = null;
- }
- }
- catch (IOException e) {
- throw e;
- }
- }
- }
- private void unload() throws Exception{
+ private void unload() {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rst = null;
String sql_insert = null;
String order_columns = "";
int orders = 0;
- int dbType = DB_TYPE_UNKNOWN;
PrintWriter pw = null;
- File fldr = null;
+ File folder = null;
ArrayList<String> alColName = null;
ArrayList<String> alColTypeName = null;
ArrayList<Integer> alIsNullable = null;
ArrayList<String> alData = null;
int tb_count = 0;
int tb_col_count = 0;
+ CmnProperty cp = null;
+ DataAccessObjects dao = null;
-
-
- if(database != null){
- if(!CmnUtils.isEmpty(prop_val[D_PROPFILE])){
- getProperties(System.getProperty(prop_val[D_PROPFILE]));
- } else {
- getProperties(DEFAULT_PROP_FILE);
- }
- }
-
- for(int i=0;i<KEYS;i++){
- if(System.getProperty(PROP_KEY[i])!=null)prop_val[i] = System.getProperty(PROP_KEY[i]);
- CmnUtils.debugPrint(PROP_KEY[i] + "=" + prop_val[i]);
- }
-
- if(!CmnUtils.isEmpty(prop_val[D_USER]))user = prop_val[D_USER];
- if(!CmnUtils.isEmpty(prop_val[D_PASS]))pass = prop_val[D_PASS];
- if(!CmnUtils.isEmpty(prop_val[D_URL]))url = prop_val[D_URL];
- if(!CmnUtils.isEmpty(prop_val[D_DRIVER]))driver = prop_val[D_DRIVER];
- if(!CmnUtils.isEmpty(prop_val[D_ORDER]) && prop_val[D_ORDER].toUpperCase().equals("Y"))isOrder = true;
- if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]) && prop_val[D_QUOTATION].toUpperCase().equals("N"))isQuotation = false;
- if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))isInclTables = true;
- if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))isExclTables = true;
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))isInclCols = true;
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))isExclCols = true;
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))isInclColsMask = true;
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))isExclColsMask = true;
- if(isInclColsMask || isExclColsMask)isMask = true;
- if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]);
- if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]);
- if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT];
- if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTables = prop_val[D_INCLTAB].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTables = prop_val[D_EXCLTAB].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclCols = prop_val[D_INCLCOL].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclCols = prop_val[D_EXCLCOL].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclMaskCols = prop_val[D_INCLCOLMASK].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclMaskCols = prop_val[D_EXCLCOLMASK].toUpperCase();
- if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTablesArray = CmnUtils.splitCsv(prop_val[D_INCLTAB].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTablesArray = CmnUtils.splitCsv(prop_val[D_EXCLTAB].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclColsArray = CmnUtils.splitCsv(prop_val[D_INCLCOL].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclColsArray = CmnUtils.splitCsv(prop_val[D_EXCLCOL].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMaskArray = CmnUtils.splitCsv(prop_val[D_INCLCOLMASK].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMaskArray = CmnUtils.splitCsv(prop_val[D_EXCLCOLMASK].toUpperCase());
- if(!CmnUtils.isEmpty(prop_val[D_SBYTEMASKCHR]))singleByteMaskChar = prop_val[D_SBYTEMASKCHR].charAt(0);
- if(!CmnUtils.isEmpty(prop_val[D_DBYTEMASKCHR]))doubleByteMaskChar = prop_val[D_DBYTEMASKCHR].charAt(0);
- if(!CmnUtils.isEmpty(prop_val[D_MASKPTN]))maskPattern = prop_val[D_MASKPTN];
- if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE];
-
- if(user == null){
- throw new Exception("user is null");
- } else if (pass == null){
- throw new Exception("password 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(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL])){
- tkSql = prop_val[D_TBLKEYSQL];
- } else {
- tkSql = tkSqlArray[dbType];
- }
- } else {
- throw new Exception("dbtype unknown");
- }
-
- DataAccessObjects dao = new DataAccessObjects(user, pass, url, driver);
- dao.setPropVal(prop_val);
try {
- conn = dao.connect();
+ cp = new CmnProperty();
+ cp.setProperty(database);
- if(outFolder != null){
- fldr = new File(outFolder);
+ if(cp.outFolder != null){
+ folder = new File(cp.outFolder);
} else {
if(database != null){
- fldr = new File(DEFAULT_FOLDER + "/" + database.toUpperCase() + "_" + CmnUtils.getYmdhm());
+ folder = new File(cp.DEFAULT_OUT_FOLDER + "/" + database.toUpperCase() + "_" + CmnUtils.getYmdhm());
} else {
- fldr = new File(DEFAULT_FOLDER + "/" + DB_TYPE_NAME[dbType].toUpperCase() + "_" + CmnUtils.getYmdhm());
+ folder = new File(cp.DEFAULT_OUT_FOLDER + "/" + cp.DB_TYPE_NAME[cp.dbType].toUpperCase() + "_" + CmnUtils.getYmdhm());
}
- fldr.mkdir();
+ folder.mkdir();
}
- if(database!=null)CmnUtils.infoPrint("-->Database='" + database.toUpperCase() + "'");
- CmnUtils.infoPrint("-->Output='" + fldr + "'");
- if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))CmnUtils.infoPrint("-->Delimiter='" + prop_val[D_DELIMITER] + "'");
- if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))CmnUtils.infoPrint("-->LineSeparator='" + prop_val[D_LINESEP] + "'");
- if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))CmnUtils.infoPrint("-->FileEncoding='" + prop_val[D_FILENCODE] + "'");
- if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]))CmnUtils.infoPrint("-->Quotation=" + CmnUtils.getYesNo(isQuotation));
- if(!CmnUtils.isEmpty(prop_val[D_ORDER]))CmnUtils.infoPrint("-->Sort=" + CmnUtils.getYesNo(isOrder));
- if(isInclTables)CmnUtils.infoPrint("-->Include Tables='" + inclTables.toUpperCase() + "'");
- if(isExclTables)CmnUtils.infoPrint("-->Exclude Tables='" + exclTables.toUpperCase() + "'");
- if(isInclCols)CmnUtils.infoPrint("-->Include Columns='" + inclCols.toUpperCase() + "'");
- if(isExclCols)CmnUtils.infoPrint("-->Exclude Columns='" + exclCols.toUpperCase() + "'");
- if(isMask){
- CmnUtils.infoPrint("-->Masking=" + CmnUtils.getYesNo(isMask));
- CmnUtils.infoPrint("-->Masking Pattern=" + maskPattern.toUpperCase());
- if(isInclColsMask)CmnUtils.infoPrint("-->Masking Columns='" + inclMaskCols.toUpperCase() + "'");
- if(isExclColsMask)CmnUtils.infoPrint("-->Exclude Masking Columns='" + exclMaskCols.toUpperCase() + "'");
- CmnUtils.infoPrint("-->Single Byte Mask Char='" + singleByteMaskChar + "'");
- CmnUtils.infoPrint("-->Double Byte Mask Char='" + doubleByteMaskChar + "'");
- }
- CmnUtils.infoPrint("Start DataUnload ---------------------------------------------");
-
- dao.select(tkSql);
+ CmnUtils.infoPrint("-->\8fo\97Í\90æ\83t\83H\83\8b\83_='" + folder + "'");
+ CmnUtils.infoPrint("\83f\81[\83^\83A\83\93\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82µ\82½\81B");
+ dao = new DataAccessObjects(cp);
+ conn = dao.connect();
+ dao.select(cp.tkSql);
alData = dao.getArrayList();
tb_count = dao.getColumnCount();
orders = 0;
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(inclTablesArray,alData.get(i).toUpperCase())){
- CmnUtils.debugPrint("inclTables=" + inclTables);
- CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(inclTablesArray,alData.get(i).toUpperCase()));
+ if(cp.isInclTables && !CmnUtils.isMatch(cp.inclTablesArray,alData.get(i).toUpperCase())){
+ CmnUtils.debugPrint("cp.inclTables=" + cp.inclTables);
+ CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(cp.inclTablesArray,alData.get(i).toUpperCase()));
orders = 0;
order_columns = "";
continue;
}
- if(isExclTables && CmnUtils.isMatch(exclTablesArray,alData.get(i).toUpperCase())){
- CmnUtils.debugPrint("exclTables=" + exclTables);
- CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(exclTablesArray,alData.get(i).toUpperCase()));
+ if(cp.isExclTables && CmnUtils.isMatch(cp.exclTablesArray,alData.get(i).toUpperCase())){
+ CmnUtils.debugPrint("cp.exclTables=" + cp.exclTables);
+ CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(cp.exclTablesArray,alData.get(i).toUpperCase()));
orders = 0;
order_columns = "";
continue;
}
if (!alData.get(i+1).equals("")){
- if(isOrder){
+ if(cp.isOrder){
if (orders == 0){
if (!alData.get(i+1).equals(""))order_columns = alData.get(i+1);
} else {
orders++;
}
}
- if(isOrder){
+ if(cp.isOrder){
if(!order_columns.equals("")){
sql_unload = "select * from " + alData.get(i) + " order by " + order_columns;
} else {
tb_col_count = dao.getColumnCount();
for(int j=0;j<alColName.size();j++){
if(CmnUtils.isColString(alColTypeName.get(j))){
- if(isMask){
+ if(cp.isMask){
if(
- (isInclColsMask &&
- !isExclColsMask &&
- CmnUtils.isMatch(inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+ (cp.isInclColsMask &&
+ !cp.isExclColsMask &&
+ CmnUtils.isMatch(cp.inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
) ||
- (isInclColsMask &&
- isExclColsMask &&
- CmnUtils.isMatch(inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) &&
- !CmnUtils.isMatch(exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+ (cp.isInclColsMask &&
+ cp.isExclColsMask &&
+ CmnUtils.isMatch(cp.inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) &&
+ !CmnUtils.isMatch(cp.exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
) ||
- (!isInclColsMask &&
- isExclColsMask &&
- !CmnUtils.isMatch(exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+ (!cp.isInclColsMask &&
+ cp.isExclColsMask &&
+ !CmnUtils.isMatch(cp.exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
)
){
CmnUtils.debugPrint("Mask Column=" + alColName.get(j).toUpperCase());
} else {
alColMask.add(false);
}
- if(isInclCols || isExclCols){
+ if(cp.isInclCols || cp.isExclCols){
if(
- (isInclCols &&
- !isExclCols &&
- CmnUtils.isMatch(inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase())
+ (cp.isInclCols &&
+ !cp.isExclCols &&
+ CmnUtils.isMatch(cp.inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase())
) ||
- (isInclCols &&
- isExclCols &&
- CmnUtils.isMatch(inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase()) &&
- !CmnUtils.isMatch(exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+ (cp.isInclCols &&
+ cp.isExclCols &&
+ CmnUtils.isMatch(cp.inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase()) &&
+ !CmnUtils.isMatch(cp.exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
) ||
- (!isInclCols &&
- isExclCols &&
- !CmnUtils.isMatch(exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
+ (!cp.isInclCols &&
+ cp.isExclCols &&
+ !CmnUtils.isMatch(cp.exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase())
)
){
CmnUtils.debugPrint("column=" + alColName.get(j).toUpperCase());
dao.setArrayColumnMaskList(alColMask);
if (lastCol >= 0){
- pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fldr + "/" + alData.get(i) + ".csv"), fileEncoding)));
+ pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(folder + "/" + alData.get(i) + ".csv"), cp.fileEncoding)));
CmnUtils.infoPrinting(String.format("%1$-30s",alData.get(i)));
for(int j=0;j<alColName.size();j++){
if(j==firstCol){
- if(isQuotation){
+ if(cp.isQuotation){
pw.print("\"" + alColName.get(j));
} else {
pw.print(alColName.get(j));
if(colIncl[j])pw.print(alColName.get(j));
}
if (firstCol == lastCol){
- if(isQuotation){
- pw.print("\"" + lineSeparator);
+ if(cp.isQuotation){
+ pw.print("\"" + cp.lineSeparator);
} else {
- pw.print("" + lineSeparator);
+ pw.print("" + cp.lineSeparator);
}
} else {
if (j==lastCol){
- if(isQuotation){
- pw.print("\"" + lineSeparator);
+ if(cp.isQuotation){
+ pw.print("\"" + cp.lineSeparator);
} else {
- pw.print("" + lineSeparator);
+ pw.print("" + cp.lineSeparator);
}
} else {
if(colIncl[j]){
- if(isQuotation){
- pw.print("\"" + delimiter + "\"");
+ if(cp.isQuotation){
+ pw.print("\"" + cp.delimiter + "\"");
} else {
- pw.print(delimiter);
+ pw.print(cp.delimiter);
}
}
}
dao.closeRecordSet();
pw.close();
pw = null;
- System.out.println(String.format("%1$10d",dao.getRecCount()) + " rows exported");
+ System.out.println(String.format("%1$10d",dao.getRecCount()) + " \8ds \83A\83\93\83\8d\81[\83h\82³\82ê\82Ü\82µ\82½\81B");
}
orders = 0;
order_columns = "";
} else {
if (!alData.get(i+1).equals("")){
- if(isOrder){
+ if(cp.isOrder){
if (orders == 0){
if (!alData.get(i+1).equals(""))order_columns = alData.get(i+1);
} else {
}
}
- dao.disconnect();
+ CmnUtils.infoPrint("\83f\81[\83^\83A\83\93\83\8d\81[\83h\82ð\8fI\97¹\82µ\82Ü\82µ\82½\81B");
} catch (Exception e) {
- throw e;
+ try{
+ CmnUtils.errorPrint(e.toString());
+ e.printStackTrace();
+ dao.rollback();
+ } catch (Exception ee) {}
} finally{
- if(pw!=null){
- pw.close();
- pw=null;
- }
+ try{
+ dao.disconnect();
+ if(stmt != null){
+ stmt.close();
+ stmt=null;
+ }
+ if(pw!=null){
+ pw.close();
+ pw=null;
+ }
+ } catch (Exception e) {}
}
- CmnUtils.infoPrint("End DataUnload -----------------------------------------------");
}