// protected static final int DB_TYPE_POSTGRESQL = 4;
protected static final int DB_TYPE_UNKNOWN = -1;
protected static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "MYSQL"};
+ protected static final String [] DB_SQL_QUOTED = {"\"", "\"", "`"};
protected static final int MASK_PTN_ALL = 0;
protected static final int MASK_PTN_ALT = 1;
protected static final int MASK_PTN_EDGE = 2;
protected static final int D_DBYTEMASKCHR = 23;
protected static final int D_MASKPTN = 24;
protected static final int D_PROPFILE = 25;
- protected static final int KEYS = 26;
+ protected static final int D_SPCPADDING = 26;
+ protected static final int D_FILEEXT = 27;
+ protected static final int D_SQLQUOTED = 28;
+ protected static final int KEYS = 29;
protected 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"};
+ "dm","ts","tks","od","qt","bc","it","et","ic","ec",
+ "icm","ecm","smc","dmc","mp","pf","sp","ext","sq"};
protected String [] prop_val = new String[KEYS];
protected static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
protected static final String DEFAULT_IN_FOLDER = "input";
protected static final String DEFAULT_OUT_FOLDER = "output";
protected static final String DEFAULT_PROP_FILE = "RapideAct.properties";
- protected static String [] tSqlArray = {
+ protected static final String [] T_SQL_ARRAY = {
"select "
+ " table_name "
+ " from user_tables "
+ " where TABLE_TYPE = 'BASE TABLE' and TABLE_SCHEMA = database() "
+ " order by table_name"
};
- protected static String [] tkSqlArray = {
+ protected static final String [] TK_SQL_ARRAY = {
"select "
+ "a.table_name,"
+ "d.column_name "
+ " a.table_name,b.ORDINAL_POSITION"
};
- protected String user = null;
- protected String pass = null;
- protected String url = null;
- protected String driver = null;
+ protected String user = null;
+ protected String pass = null;
+ protected String url = null;
+ protected String driver = null;
protected String outFolder = null;
protected String inFolder = null;
protected String lineSeparator = System.getProperty("line.separator");
- protected String inColLineSeparator = System.getProperty("line.separator");
+ protected String inColLineSeparator = System.getProperty("line.separator");
protected String fileEncoding = System.getProperty("file.encoding");
protected String nullMark = "";
protected String delimiter = "\t";
- protected String tSql = null;
- protected String tkSql = null;
+ protected String fileExtension = "tsv";
+ protected boolean isSpcPadding = false;
+ protected String sqlQuoted = null;
+ protected String tSql = null;
+ protected String tkSql = null;
protected boolean isOrder = false;
protected boolean isQuotation = true;
- protected int batchCount = 1000;
- protected String inclTables = null;
- protected String exclTables = null;
+ protected int batchCount = 1000;
+ protected String inclTables = null;
+ protected String exclTables = null;
protected String inclCols = null;
protected String exclCols = null;
protected String inclColsMask = null;
protected String exclColsMask = null;
- protected char singleByteMaskChar = '*';
+ protected char singleByteMaskChar = '*';
protected char doubleByteMaskChar = '\u25A0';
- protected String maskPattern = "ALT";
+ protected String maskPattern = "ALT";
- protected String [] inclTablesArray = null;
- protected String [] exclTablesArray = null;
- protected String [] inclColsArray = null;
- protected String [] exclColsArray = null;
- protected String [] inclColsMaskArray = null;
- protected String [] exclColsMaskArray = null;
+ protected String [] inclTablesArray = null;
+ protected String [] exclTablesArray = null;
+ protected String [] inclColsArray = null;
+ protected String [] exclColsArray = null;
+ protected String [] inclColsMaskArray = null;
+ protected String [] exclColsMaskArray = null;
protected boolean isInclTables = false;
protected boolean isExclTables = false;
- protected boolean isInclCols = false;
- protected boolean isExclCols = false;
- protected boolean isMask = false;
- protected boolean isInclColsMask = false;
- protected boolean isExclColsMask = false;
- protected int dbType = DB_TYPE_UNKNOWN;
+ protected boolean isInclCols = false;
+ protected boolean isExclCols = false;
+ protected boolean isMask = false;
+ protected boolean isInclColsMask = false;
+ protected boolean isExclColsMask = false;
+ protected int dbType = DB_TYPE_UNKNOWN;
protected void getProperties(String _propFile) throws Exception{
BufferedReader br = null;
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_SPCPADDING]) && prop_val[D_SPCPADDING].toUpperCase().equals("Y"))isSpcPadding = true;
+ if(!CmnUtils.isEmpty(prop_val[D_FILEEXT]))fileExtension = prop_val[D_FILEEXT];
if(CmnUtils.isEmpty(user)){
throw new Exception("us(\83\86\81[\83UID)\82ª\96¢\8ew\92è\82Å\82·\81B");
if (dbType != DB_TYPE_UNKNOWN){
if(!CmnUtils.isEmpty(prop_val[D_TBLSQL])){
tSql = prop_val[D_TBLSQL];
+ } else {
+ tSql = T_SQL_ARRAY[dbType];
+ }
+ if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL])){
tkSql = prop_val[D_TBLKEYSQL];
} else {
- tSql = tSqlArray[dbType];
- tkSql = tkSqlArray[dbType];
+ tkSql = TK_SQL_ARRAY[dbType];
+ }
+ if(!CmnUtils.isEmpty(prop_val[D_SQLQUOTED])){
+ sqlQuoted = prop_val[D_SQLQUOTED];
+ } else {
+ sqlQuoted = DB_SQL_QUOTED[dbType];
}
} else {
throw new Exception("\83f\81[\83^\83x\81[\83X\90»\95i\82ª\8e¯\95Ê\82Å\82«\82Ü\82¹\82ñ\81B[" + url + "]");
}
if(database!=null)CmnUtils.infoPrint("-->\91Î\8fÛ\83f\81[\83^\83x\81[\83X='" + database.toUpperCase() + "'");
+ if(!CmnUtils.isEmpty(prop_val[D_FILEEXT]))CmnUtils.infoPrint("-->\83t\83@\83C\83\8b\8ag\92£\8eq='" + prop_val[D_FILEEXT] + "'");
if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))CmnUtils.infoPrint("-->\8bæ\90Ø\82è\95¶\8e\9a='" + prop_val[D_DELIMITER] + "'");
if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))CmnUtils.infoPrint("-->\89ü\8ds\83R\81[\83h='" + prop_val[D_LINESEP] + "'");
if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))CmnUtils.infoPrint("-->\83J\83\89\83\80\93à\89ü\8ds\83R\81[\83h='" + prop_val[D_INLINESEP] + "'");
if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))CmnUtils.infoPrint("-->\95¶\8e\9a\83R\81[\83h='" + prop_val[D_FILENCODE] + "'");
if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]))CmnUtils.infoPrint("-->\88ø\97p\8bå=" + CmnUtils.getYesNo(isQuotation));
+ if(!CmnUtils.isEmpty(prop_val[D_SQLQUOTED]))CmnUtils.infoPrint("-->SQL\88ø\97p\95\84=" + "'" + sqlQuoted + "'");
if(!CmnUtils.isEmpty(prop_val[D_ORDER]))CmnUtils.infoPrint("-->\83\\81[\83g=" + CmnUtils.getYesNo(isOrder));
if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))CmnUtils.infoPrint("-->\83o\83b\83`\8f\88\97\9d\90\94=" + batchCount);
+ if(isSpcPadding)CmnUtils.infoPrint("-->\8bó\94\92\96\84\82ß=" + CmnUtils.getYesNo(isSpcPadding));
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() + "'");
import java.util.Iterator;
import java.math.BigInteger;
import java.math.BigDecimal;
+import java.nio.charset.Charset;
public class DataAccessObjects{
private int ColumnCount = 0;
private ArrayList<String> alColName = null;
private ArrayList<String> alColTypeName = null;
+ private ArrayList<Integer> alColPrecision = null;
private ArrayList<Integer> alIsNullable = null;
private ArrayList<Boolean> alColMask = null;
private ArrayList<Boolean> alColIncl = null;
private static String sql="select sysdate from dual";
private String[] colTypeName = null;
private String[] colName = null;
+ private Integer[] colPrecision = null;
private Integer[] isNullable = null;
private Boolean [] colMask = null;
private Boolean [] colIncl = null;
CmnUtils.debugPrint("End get ColumnCount," + ColumnCount);
alColTypeName = new ArrayList<String>();
alColName = new ArrayList<String>();
+ alColPrecision = new ArrayList<Integer>();
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));
+ alColPrecision.add(rsmd.getPrecision(i + 1));
alIsNullable.add(rsmd.isNullable(i + 1));
}
colTypeName = (String[])alColTypeName.toArray(new String[0]);
colName = (String[])alColName.toArray(new String[0]);
+ colPrecision = (Integer[])alColPrecision.toArray(new Integer[0]);
isNullable = (Integer[])alIsNullable.toArray(new Integer[0]);
}
return alIsNullable;
}
+ public ArrayList<Integer> getArrayPrecisionList() throws Exception{
+ return alColPrecision;
+ }
+
public void setArrayColumnMaskList(ArrayList<Boolean> _alColMask) throws Exception{
alColMask = _alColMask;
colMask = (Boolean[])alColMask.toArray(new Boolean[0]);
colString = getColString(rst, i + 1, colTypeName[i], isNullable[i], colMask[i]);
if (colString != null) {
+ if(CmnUtils.isFixString(colTypeName[i]) && cp.isSpcPadding)colString = colString + CmnUtils.padSpace(colString, colPrecision[i], Charset.forName(cp.fileEncoding));
if (i == _firstCol){
if(cp.isQuotation){
if (_firstCol == _lastCol){