• R/O
  • HTTP
  • SSH
  • HTTPS

rapideact: Commit


Commit MetaInfo

Revision51d8bdcf83067acf076789244974c0e5feea373e (tree)
Time2017-01-27 07:53:26
Authorkuboryu <kuboryu@yaho...>
Commiterkuboryu

Log Message

20170127

Change Summary

Incremental Difference

--- /dev/null
+++ b/com/rapide_act/CmnProperty.java
@@ -0,0 +1,311 @@
1+package com.rapide_act;
2+
3+import java.io.BufferedInputStream;
4+import java.io.BufferedReader;
5+import java.io.BufferedWriter;
6+import java.io.FileInputStream;
7+import java.io.InputStream;
8+import java.io.InputStreamReader;
9+import java.io.IOException;
10+import java.io.File;
11+import java.io.FileReader;
12+import java.io.FileWriter;
13+import java.io.PrintWriter;
14+import java.io.PrintWriter;
15+import java.util.Date;
16+import java.util.ArrayList;
17+import java.util.Iterator;
18+import java.util.Properties;
19+import java.sql.Blob;
20+import java.sql.Clob;
21+import java.sql.Connection;
22+import java.sql.DriverManager;
23+import java.sql.PreparedStatement;
24+import java.sql.ResultSet;
25+import java.sql.ResultSetMetaData;
26+import java.sql.SQLException;
27+import java.sql.Timestamp;
28+import java.math.BigDecimal;
29+
30+public class CmnProperty{
31+ protected String database = null;
32+ protected static final int DB_TYPE_ORACLE = 0;
33+ protected static final int DB_TYPE_SQLSERVER = 1;
34+ protected static final int DB_TYPE_DB2 = 2;
35+ protected static final int DB_TYPE_MYSQL = 3;
36+ protected static final int DB_TYPE_POSTGRESQL = 4;
37+ protected static final int DB_TYPE_UNKNOWN = -1;
38+ protected static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"};
39+ protected static final int MASK_PTN_ALL = 0;
40+ protected static final int MASK_PTN_ALT = 1;
41+ protected static final int MASK_PTN_EDGE = 2;
42+ protected static final int D_USER = 0;
43+ protected static final int D_PASS = 1;
44+ protected static final int D_URL = 2;
45+ protected static final int D_DRIVER = 3;
46+ protected static final int D_OUTPUT = 4;
47+ protected static final int D_INPUT = 5;
48+ protected static final int D_LINESEP = 6;
49+ protected static final int D_INLINESEP = 7;
50+ protected static final int D_FILENCODE = 8;
51+ protected static final int D_NULLMARK = 9;
52+ protected static final int D_DELIMITER = 10;
53+ protected static final int D_TBLSQL = 11;
54+ protected static final int D_TBLKEYSQL = 12;
55+ protected static final int D_ORDER = 13;
56+ protected static final int D_QUOTATION = 14;
57+ protected static final int D_BATCOUNT = 15;
58+ protected static final int D_INCLTAB = 16;
59+ protected static final int D_EXCLTAB = 17;
60+ protected static final int D_INCLCOL = 18;
61+ protected static final int D_EXCLCOL = 19;
62+ protected static final int D_INCLCOLMASK = 20;
63+ protected static final int D_EXCLCOLMASK = 21;
64+ protected static final int D_SBYTEMASKCHR = 22;
65+ protected static final int D_DBYTEMASKCHR = 23;
66+ protected static final int D_MASKPTN = 24;
67+ protected static final int D_PROPFILE = 25;
68+ protected static final int KEYS = 26;
69+ protected static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm",
70+ "dm","ts","tks","od","qt","bc","it","et","ic","ec",
71+ "icm","ecm","smc","dmc","mp","pf"};
72+
73+ protected String [] prop_val = new String[KEYS];
74+ protected static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
75+ protected static final String DEFAULT_IN_FOLDER = "input";
76+ protected static final String DEFAULT_PROP_FILE = "RapideLoader.properties";
77+ protected static String [] tSqlArray = {
78+ "select "
79+ + " table_name "
80+ + " from user_tables "
81+ + " order by table_name",
82+ "select "
83+ + " name as table_name "
84+ + " from sys.tables "
85+ + " order by name"
86+ };
87+ protected static String [] tkSqlArray = {
88+ "select "
89+ + "a.table_name,"
90+ + "d.column_name "
91+ + " from user_tables a,"
92+ + " (select b.table_name, "
93+ + " c.column_name, "
94+ + " c.position "
95+ + " from user_constraints b, "
96+ + " user_cons_columns c "
97+ + " where b.CONSTRAINT_TYPE = 'P' and "
98+ + " b.TABLE_NAME = c.TABLE_NAME and "
99+ + " b.CONSTRAINT_NAME = c.CONSTRAINT_NAME "
100+ + " ) d "
101+ + "where a.table_name = d.table_name(+) "
102+ + "order by a.table_name, d.position",
103+ "SELECT "
104+ + " A.name AS table_name, "
105+ + " D.name AS col_name "
106+ + "FROM sys.tables AS A "
107+ + "LEFT OUTER JOIN sys.key_constraints AS B "
108+ + "ON A.object_id = B.parent_object_id "
109+ + " AND B.type = 'PK' "
110+ + "LEFT OUTER JOIN sys.index_columns AS C "
111+ + "ON B.parent_object_id = C.object_id "
112+ + " AND B.unique_index_id = C.index_id "
113+ + "LEFT OUTER JOIN sys.columns AS D "
114+ + "ON C.object_id = D.object_id "
115+ + " AND C.column_id = D.column_id "
116+ + "order by A.name,C.key_ordinal"
117+ };
118+
119+ protected String user = null;
120+ protected String pass = null;
121+ protected String url = null;
122+ protected String driver = null;
123+ protected String outFolder = null;
124+ protected String inFolder = null;
125+ protected String lineSeparator = System.getProperty("line.separator");
126+ protected String inColLineSeparator = System.getProperty("line.separator");
127+ protected String fileEncoding = System.getProperty("file.encoding");
128+ protected String nullMark = "";
129+ protected String delimiter = "\t";
130+ protected String tSql = null;
131+ protected String tkSql = null;
132+ protected boolean isOrder = false;
133+ protected boolean isQuotation = true;
134+ protected int batchCount = 1000;
135+ protected String inclTables = null;
136+ protected String exclTables = null;
137+ protected String inclCols = null;
138+ protected String exclCols = null;
139+ protected String inclColsMask = null;
140+ protected String exclColsMask = null;
141+ protected char singleByteMaskChar = '*';
142+ protected char doubleByteMaskChar = '\u25A0';
143+ protected String maskPattern = "ALT";
144+
145+ protected String [] inclTablesArray = null;
146+ protected String [] exclTablesArray = null;
147+ protected String [] inclColsArray = null;
148+ protected String [] exclColsArray = null;
149+ protected String [] inclColsMaskArray = null;
150+ protected String [] exclColsMaskArray = null;
151+ protected boolean isInclTables = false;
152+ protected boolean isExclTables = false;
153+ protected boolean isInclCols = false;
154+ protected boolean isExclCols = false;
155+ protected boolean isMask = false;
156+ protected boolean isInclColsMask = false;
157+ protected boolean isExclColsMask = false;
158+ protected int dbType = DB_TYPE_UNKNOWN;
159+
160+ protected void getProperties(String _propFile) throws Exception{
161+ BufferedReader br = null;
162+ Properties prop = null;
163+ try {
164+ prop = new Properties();
165+ br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(_propFile), "UTF-8"));
166+ prop.load(br);
167+ for(int i=0;i<KEYS;i++){
168+ prop_val[i] = prop.getProperty(database + "." +PROP_KEY[i]);
169+ }
170+ br.close();
171+ br = null;
172+ } catch (NullPointerException e) {
173+ throw new Exception("Property File (" + _propFile +") Not Found");
174+ } catch (IOException e) {
175+ throw e;
176+ }
177+ finally{
178+ try {
179+ if (br != null) {
180+ br.close();
181+ br = null;
182+ }
183+ }
184+ catch (IOException e) {
185+ throw e;
186+ }
187+ }
188+ }
189+
190+
191+ CmnProperty() {
192+ super();
193+ }
194+
195+ protected void setProperty(String _database) throws Exception{
196+ database = _database;
197+ if(database != null){
198+ if(!CmnUtils.isEmpty(prop_val[D_PROPFILE])){
199+ getProperties(System.getProperty(prop_val[D_PROPFILE]));
200+ } else {
201+ getProperties(DEFAULT_PROP_FILE);
202+ }
203+ }
204+
205+ for(int i=0;i<KEYS;i++){
206+ if(System.getProperty(PROP_KEY[i])!=null)prop_val[i] = System.getProperty(PROP_KEY[i]);
207+ CmnUtils.debugPrint(PROP_KEY[i] + "=" + prop_val[i]);
208+ }
209+
210+ if(!CmnUtils.isEmpty(prop_val[D_USER]))user = prop_val[D_USER];
211+ if(!CmnUtils.isEmpty(prop_val[D_PASS]))pass = prop_val[D_PASS];
212+ if(!CmnUtils.isEmpty(prop_val[D_URL]))url = prop_val[D_URL];
213+ if(!CmnUtils.isEmpty(prop_val[D_DRIVER]))driver = prop_val[D_DRIVER];
214+ if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT];
215+ if(!CmnUtils.isEmpty(prop_val[D_INPUT]))inFolder = prop_val[D_INPUT];
216+ if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]);
217+ if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))inColLineSeparator = CmnUtils.getLineSeparator(prop_val[D_INLINESEP]);
218+ if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE];
219+ if(!CmnUtils.isEmpty(prop_val[D_NULLMARK]))nullMark = prop_val[D_NULLMARK];
220+ if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]);
221+ if(!CmnUtils.isEmpty(prop_val[D_TBLSQL]))tSql = prop_val[D_TBLSQL];
222+ if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL]))tkSql = prop_val[D_TBLKEYSQL];
223+ if(!CmnUtils.isEmpty(prop_val[D_ORDER]) && prop_val[D_ORDER].toUpperCase().equals("Y"))isOrder = true;
224+ if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]) && prop_val[D_QUOTATION].toUpperCase().equals("N"))isQuotation = false;
225+ if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))batchCount = Integer.parseInt(prop_val[D_BATCOUNT]);
226+ if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))isInclTables = true;
227+ if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))isExclTables = true;
228+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))isInclCols = true;
229+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))isExclCols = true;
230+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))isInclColsMask = true;
231+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))isExclColsMask = true;
232+ if(isInclColsMask || isExclColsMask)isMask = true;
233+ if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTables = prop_val[D_INCLTAB].toUpperCase();
234+ if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTables = prop_val[D_EXCLTAB].toUpperCase();
235+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclCols = prop_val[D_INCLCOL].toUpperCase();
236+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclCols = prop_val[D_EXCLCOL].toUpperCase();
237+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMask = prop_val[D_INCLCOLMASK].toUpperCase();
238+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMask = prop_val[D_EXCLCOLMASK].toUpperCase();
239+ if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTablesArray = CmnUtils.splitCsv(prop_val[D_INCLTAB].toUpperCase());
240+ if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTablesArray = CmnUtils.splitCsv(prop_val[D_EXCLTAB].toUpperCase());
241+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclColsArray = CmnUtils.splitCsv(prop_val[D_INCLCOL].toUpperCase());
242+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclColsArray = CmnUtils.splitCsv(prop_val[D_EXCLCOL].toUpperCase());
243+ if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMaskArray = CmnUtils.splitCsv(prop_val[D_INCLCOLMASK].toUpperCase());
244+ if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMaskArray = CmnUtils.splitCsv(prop_val[D_EXCLCOLMASK].toUpperCase());
245+ if(!CmnUtils.isEmpty(prop_val[D_SBYTEMASKCHR]))singleByteMaskChar = prop_val[D_SBYTEMASKCHR].charAt(0);
246+ if(!CmnUtils.isEmpty(prop_val[D_DBYTEMASKCHR]))doubleByteMaskChar = prop_val[D_DBYTEMASKCHR].charAt(0);
247+ if(!CmnUtils.isEmpty(prop_val[D_MASKPTN]))maskPattern = prop_val[D_MASKPTN];
248+
249+ if(user == null){
250+ throw new Exception("user is null");
251+ } else if (pass == null){
252+ throw new Exception("pass is null");
253+ } else if (url == null){
254+ throw new Exception("url is null");
255+ } else if (driver == null){
256+ throw new Exception("driver is null");
257+ }
258+
259+ for(int i = 0;i<DB_TYPE_NAME.length;i++){
260+ if (url.toUpperCase().contains(DB_TYPE_NAME[i])){
261+ dbType = i;
262+ break;
263+ }
264+ }
265+
266+ if (dbType != DB_TYPE_UNKNOWN){
267+ if(!CmnUtils.isEmpty(prop_val[D_TBLSQL])){
268+ tSql = prop_val[D_TBLSQL];
269+ } else {
270+ tSql = tSqlArray[dbType];
271+ }
272+ } else {
273+ throw new Exception("dbtype unknown");
274+ }
275+
276+ if (dbType != DB_TYPE_UNKNOWN){
277+ if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL])){
278+ tkSql = prop_val[D_TBLKEYSQL];
279+ } else {
280+ tkSql = tkSqlArray[dbType];
281+ }
282+ } else {
283+ throw new Exception("dbtype unknown");
284+ }
285+
286+ if(database!=null)CmnUtils.infoPrint("-->対象データベース='" + database.toUpperCase() + "'");
287+ if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))CmnUtils.infoPrint("-->区切り文字='" + prop_val[D_DELIMITER] + "'");
288+ if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))CmnUtils.infoPrint("-->改行コード='" + prop_val[D_LINESEP] + "'");
289+ if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))CmnUtils.infoPrint("-->カラム内改行コード='" + prop_val[D_INLINESEP] + "'");
290+ if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))CmnUtils.infoPrint("-->文字コード='" + prop_val[D_FILENCODE] + "'");
291+ if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]))CmnUtils.infoPrint("-->引用句=" + CmnUtils.getYesNo(isQuotation));
292+ if(!CmnUtils.isEmpty(prop_val[D_ORDER]))CmnUtils.infoPrint("-->ソート=" + CmnUtils.getYesNo(isOrder));
293+ if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))CmnUtils.infoPrint("-->バッチ処理数=" + batchCount);
294+ if(isInclTables)CmnUtils.infoPrint("-->対象テーブル='" + inclTables.toUpperCase() + "'");
295+ if(isExclTables)CmnUtils.infoPrint("-->除外テーブル='" + exclTables.toUpperCase() + "'");
296+ if(isInclCols)CmnUtils.infoPrint("-->対象カラム='" + inclCols.toUpperCase() + "'");
297+ if(isExclCols)CmnUtils.infoPrint("-->除外カラム='" + exclCols.toUpperCase() + "'");
298+ if(isMask){
299+ CmnUtils.infoPrint("-->マスキング=" + CmnUtils.getYesNo(isMask));
300+ CmnUtils.infoPrint("-->マスクキングパターン=" + maskPattern.toUpperCase());
301+ CmnUtils.infoPrint("-->半角マスク文字='" + singleByteMaskChar + "'");
302+ CmnUtils.infoPrint("-->全角マスク文字='" + doubleByteMaskChar + "'");
303+ if(isInclColsMask)CmnUtils.infoPrint("-->マスク対象カラム='" + inclColsMask.toUpperCase() + "'");
304+ if(isExclColsMask)CmnUtils.infoPrint("-->マスク除外カラム='" + exclColsMask.toUpperCase() + "'");
305+ }
306+
307+ }
308+
309+
310+}
311+
--- a/com/rapide_act/RapideLoader.java
+++ b/com/rapide_act/RapideLoader.java
@@ -29,103 +29,7 @@ import java.math.BigDecimal;
2929
3030 public class RapideLoader{
3131 private String database = null;
32- private String user = null;
33- private String pass = null;
34- private String url = null;
35- private String driver = null;
36- private String sql_table_list = null;
37- private String sql_table_key_list = null;
38- private static final int DB_TYPE_ORACLE = 0;
39- private static final int DB_TYPE_SQLSERVER = 1;
40- private static final int DB_TYPE_DB2 = 2;
41- private static final int DB_TYPE_MYSQL = 3;
42- private static final int DB_TYPE_POSTGRESQL = 4;
43- private static final int DB_TYPE_UNKNOWN = -1;
44- private static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"};
45- private static final int MASK_PTN_ALL = 0;
46- private static final int MASK_PTN_ALT = 1;
47- private static final int MASK_PTN_EDGE = 2;
48- private static final int D_USER = 0;
49- private static final int D_PASS = 1;
50- private static final int D_URL = 2;
51- private static final int D_DRIVER = 3;
52- private static final int D_OUTPUT = 4;
53- private static final int D_INPUT = 5;
54- private static final int D_LINESEP = 6;
55- private static final int D_INLINESEP = 7;
56- private static final int D_FILENCODE = 8;
57- private static final int D_NULLMARK = 9;
58- private static final int D_DELIMITER = 10;
59- private static final int D_TBLSQL = 11;
60- private static final int D_TBLKEYSQL = 12;
61- private static final int D_ORDER = 13;
62- private static final int D_QUOTATION = 14;
63- private static final int D_BATCOUNT = 15;
64- private static final int D_INCLTAB = 16;
65- private static final int D_EXCLTAB = 17;
66- private static final int D_INCLCOL = 18;
67- private static final int D_EXCLCOL = 19;
68- private static final int D_INCLCOLMASK = 20;
69- private static final int D_EXCLCOLMASK = 21;
70- private static final int D_SBYTEMASKCHR = 22;
71- private static final int D_DBYTEMASKCHR = 23;
72- private static final int D_MASKPTN = 24;
73- private static final int D_PROPFILE = 25;
74- private static final int KEYS = 26;
75- private static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm",
76- "dm","ts","tks","od","qt","bc","it","et","ic","ec",
77- "icm","ecm","smc","dmc","mp","pf"};
7832
79- private String [] prop_val = new String[KEYS];
80- private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
81- private static final String DEFAULT_IN_FOLDER = "input";
82- private static final String DEFAULT_PROP_FILE = "RapideLoader.properties";
83- private static String [] sql_table_list_array = {
84- "select "
85- + " table_name "
86- + " from user_tables "
87- + " order by table_name",
88- "select "
89- + " name as table_name "
90- + " from sys.tables "
91- + " order by name"
92- };
93-
94- private boolean isLob = false;
95- private boolean isContinue = false;
96- private String nullMark = "";
97- private boolean isOrder = false;
98- private boolean isQuotation = true;
99- private int batchCount = 1000;
100- private boolean isInclTables = false;
101- private boolean isExclTables = false;
102- private boolean isInclCols = false;
103- private boolean isExclCols = false;
104- private boolean isMask = false;
105- private boolean isInclColsMask = false;
106- private boolean isExclColsMask = false;
107- private String delimiter = "\t";
108- private String lineSeparator = System.getProperty("line.separator");
109- private String inColLineSeparator = System.getProperty("line.separator");
110- private String outFolder = null;
111- private String inFolder = null;
112- private String inclTables = null;
113- private String exclTables = null;
114- private String inclCols = null;
115- private String exclCols = null;
116- private String inclColsMask = null;
117- private String exclColsMask = null;
118- private String [] inclTablesArray = null;
119- private String [] exclTablesArray = null;
120- private String [] inclColsArray = null;
121- private String [] exclColsArray = null;
122- private String [] inclColsMaskArray = null;
123- private String [] exclColsMaskArray = null;
124- private char singleByteMaskChar = '*';
125- private char doubleByteMaskChar = '\u25A0';
126- private String maskPattern = "ALT";
127- private String fileEncoding = System.getProperty("file.encoding");
128-
12933 public static void main(String args[]){
13034 try {
13135 if (args.length > 0){
@@ -136,38 +40,13 @@ public class RapideLoader{
13640 rapideLoader.load();
13741 }
13842 } catch (Exception e) {
139- e.printStackTrace();
140- }
141- }
142-
143- private void getProperties(String _propFile) throws Exception{
144- BufferedReader br = null;
145- Properties prop = null;
146- try {
147- prop = new Properties();
148- br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(_propFile), "UTF-8"));
149- prop.load(br);
150- for(int i=0;i<KEYS;i++){
151- prop_val[i] = prop.getProperty(database + "." +PROP_KEY[i]);
43+ try{
44+ CmnUtils.errorPrint(e.toString());
45+ e.printStackTrace();
46+ } catch (Exception ee){
47+ ee.printStackTrace();
15248 }
153- br.close();
154- br = null;
155- } catch (NullPointerException e) {
156- throw new Exception("Property File (" + _propFile +") Not Found");
157- } catch (IOException e) {
158- throw e;
15949 }
160- finally{
161- try {
162- if (br != null) {
163- br.close();
164- br = null;
165- }
166- }
167- catch (IOException e) {
168- throw e;
169- }
170- }
17150 }
17251
17352
@@ -183,7 +62,6 @@ public class RapideLoader{
18362 BufferedReader br = null;
18463 String sql_load = null;
18564 String sql_insert = null;
186- int dbType = DB_TYPE_UNKNOWN;
18765 String strLine = null;
18866 String strMltLine = null;
18967 String tbName = null;
@@ -194,7 +72,7 @@ public class RapideLoader{
19472 Integer [] isNullable = null;
19573 Boolean [] colIncl = null;
19674
197- File fldr = null;
75+ File folder = null;
19876 ArrayList<String> alData = null;
19977 ArrayList<String> alColName = null;
20078 ArrayList<String> alColTypeName = null;
@@ -205,130 +83,37 @@ public class RapideLoader{
20583 int tb_count = 0;
20684 int tb_col_count = 0;
20785 int fl_col_count = 0;
86+ boolean isLob = false;
87+ boolean isContinue = false;
20888
209-
210-
211-
212- if(database != null){
213- if(!CmnUtils.isEmpty(prop_val[D_PROPFILE])){
214- getProperties(System.getProperty(prop_val[D_PROPFILE]));
215- } else {
216- getProperties(DEFAULT_PROP_FILE);
217- }
218- }
89+ CmnProperty cp = new CmnProperty();
90+ cp.setProperty(database);
21991
220- for(int i=0;i<KEYS;i++){
221- if(System.getProperty(PROP_KEY[i])!=null)prop_val[i] = System.getProperty(PROP_KEY[i]);
222- CmnUtils.debugPrint(PROP_KEY[i] + "=" + prop_val[i]);
223- }
224-
225- if(!CmnUtils.isEmpty(prop_val[D_USER]))user = prop_val[D_USER];
226- if(!CmnUtils.isEmpty(prop_val[D_PASS]))pass = prop_val[D_PASS];
227- if(!CmnUtils.isEmpty(prop_val[D_URL]))url = prop_val[D_URL];
228- if(!CmnUtils.isEmpty(prop_val[D_DRIVER]))driver = prop_val[D_DRIVER];
229- if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT];
230- if(!CmnUtils.isEmpty(prop_val[D_INPUT]))inFolder = prop_val[D_INPUT];
231- if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]);
232- if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))inColLineSeparator = CmnUtils.getLineSeparator(prop_val[D_INLINESEP]);
233- if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE];
234- if(!CmnUtils.isEmpty(prop_val[D_NULLMARK]))nullMark = prop_val[D_NULLMARK];
235- if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]);
236- if(!CmnUtils.isEmpty(prop_val[D_TBLSQL]))sql_table_list = prop_val[D_TBLSQL];
237- if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL]))sql_table_key_list = prop_val[D_TBLKEYSQL];
238- if(!CmnUtils.isEmpty(prop_val[D_ORDER]) && prop_val[D_ORDER].toUpperCase().equals("Y"))isOrder = true;
239- if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]) && prop_val[D_QUOTATION].toUpperCase().equals("N"))isQuotation = false;
240- if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))batchCount = Integer.parseInt(prop_val[D_BATCOUNT]);
241- if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))isInclTables = true;
242- if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))isExclTables = true;
243- if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))isInclCols = true;
244- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))isExclCols = true;
245- if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))isInclColsMask = true;
246- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))isExclColsMask = true;
247- if(isInclColsMask || isExclColsMask)isMask = true;
248- if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTables = prop_val[D_INCLTAB].toUpperCase();
249- if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTables = prop_val[D_EXCLTAB].toUpperCase();
250- if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclCols = prop_val[D_INCLCOL].toUpperCase();
251- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclCols = prop_val[D_EXCLCOL].toUpperCase();
252- if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMask = prop_val[D_INCLCOLMASK].toUpperCase();
253- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMask = prop_val[D_EXCLCOLMASK].toUpperCase();
254- if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTablesArray = CmnUtils.splitCsv(prop_val[D_INCLTAB].toUpperCase());
255- if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTablesArray = CmnUtils.splitCsv(prop_val[D_EXCLTAB].toUpperCase());
256- if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclColsArray = CmnUtils.splitCsv(prop_val[D_INCLCOL].toUpperCase());
257- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclColsArray = CmnUtils.splitCsv(prop_val[D_EXCLCOL].toUpperCase());
258- if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMaskArray = CmnUtils.splitCsv(prop_val[D_INCLCOLMASK].toUpperCase());
259- if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMaskArray = CmnUtils.splitCsv(prop_val[D_EXCLCOLMASK].toUpperCase());
260- if(!CmnUtils.isEmpty(prop_val[D_SBYTEMASKCHR]))singleByteMaskChar = prop_val[D_SBYTEMASKCHR].charAt(0);
261- if(!CmnUtils.isEmpty(prop_val[D_DBYTEMASKCHR]))doubleByteMaskChar = prop_val[D_DBYTEMASKCHR].charAt(0);
262- if(!CmnUtils.isEmpty(prop_val[D_MASKPTN]))maskPattern = prop_val[D_MASKPTN];
263-
264- if(user == null){
265- throw new Exception("user is null");
266- } else if (pass == null){
267- throw new Exception("pass is null");
268- } else if (url == null){
269- throw new Exception("url is null");
270- } else if (driver == null){
271- throw new Exception("driver is null");
272- }
273-
274- for(int i = 0;i<DB_TYPE_NAME.length;i++){
275- if (url.toUpperCase().contains(DB_TYPE_NAME[i])){
276- dbType = i;
277- break;
278- }
279- }
280-
281- if (dbType != DB_TYPE_UNKNOWN){
282- if(!CmnUtils.isEmpty(prop_val[D_TBLSQL])){
283- sql_table_list = prop_val[D_TBLSQL];
284- } else {
285- sql_table_list = sql_table_list_array[dbType];
286- }
287- } else {
288- throw new Exception("dbtype unknown");
289- }
290-
291- DataAccessObjects dao = new DataAccessObjects(user, pass, url, driver);
92+ DataAccessObjects dao = new DataAccessObjects(cp.user, cp.pass, cp.url, cp.driver);
29293 try {
29394 conn = dao.connect();
29495 conn.setAutoCommit(false);
29596
296- if(inFolder != null){
297- fldr = new File(inFolder);
97+ if(cp.inFolder != null){
98+ folder = new File(cp.inFolder);
29899 } else {
299100 if (database != null){
300- fldr = new File(DEFAULT_IN_FOLDER + "/" + database.toUpperCase());
101+ folder = new File(cp.DEFAULT_IN_FOLDER + "/" + database.toUpperCase());
301102 } else {
302- fldr = new File(DEFAULT_IN_FOLDER + "/" + DB_TYPE_NAME[dbType].toUpperCase());
103+ folder = new File(cp.DEFAULT_IN_FOLDER + "/" + cp.DB_TYPE_NAME[cp.dbType].toUpperCase());
303104 }
304105 }
305- CmnUtils.infoPrint("-->対象データベース='" + database.toUpperCase() + "'");
306- CmnUtils.infoPrint("-->入力元='" + fldr + "'");
307- CmnUtils.infoPrint("-->区切り文字='" + delimiter + "'");
308- CmnUtils.infoPrint("-->バッチカウント=" + batchCount);
309- CmnUtils.infoPrint("-->引用句=" + CmnUtils.getYesNo(isQuotation));
310- if(isInclTables)CmnUtils.infoPrint("-->対象テーブル='" + inclTables.toUpperCase() + "'");
311- if(isExclTables)CmnUtils.infoPrint("-->除外テーブル='" + exclTables.toUpperCase() + "'");
312- if(isInclCols)CmnUtils.infoPrint("-->対象カラム='" + inclCols.toUpperCase() + "'");
313- if(isExclCols)CmnUtils.infoPrint("-->除外カラム='" + exclCols.toUpperCase() + "'");
314- CmnUtils.infoPrint("-->マスキング=" + CmnUtils.getYesNo(isMask));
315- if(isMask){
316- CmnUtils.infoPrint("-->マスクキングパターン=" + maskPattern.toUpperCase());
317- if(isInclColsMask)CmnUtils.infoPrint("-->マスク対象カラム='" + inclColsMask.toUpperCase() + "'");
318- if(isExclColsMask)CmnUtils.infoPrint("-->マスク除外カラム='" + exclColsMask.toUpperCase() + "'");
319- CmnUtils.infoPrint("-->半角マスク文字='" + singleByteMaskChar + "'");
320- CmnUtils.infoPrint("-->全角マスク文字='" + doubleByteMaskChar + "'");
321- }
106+ CmnUtils.infoPrint("-->入力元='" + folder + "'");
322107 CmnUtils.infoPrint("データロードを開始しました。");
323108
324- dao.select(sql_table_list);
109+ dao.select(cp.tSql);
325110 alData = dao.getArrayList();
326111 tb_count = dao.getColumnCount();
327112 int tb_rec_count = 0;
328113 int fl_rec_count = 0;
329114 int ins_rec_count = 0;
330115 int tb_fl_match_count = 0;
331- File [] inFiles = fldr.listFiles();
116+ File [] inFiles = folder.listFiles();
332117 if(inFiles != null) {
333118 for(int k=0;k<inFiles.length;k++){
334119 flName = CmnUtils.splitDot(inFiles[k].getName());
@@ -337,17 +122,17 @@ public class RapideLoader{
337122 TABLE_LOOP:
338123 for(int i=0;i<alData.size();i++){
339124 if(tbName.equals(alData.get(i))){
340- if(isInclTables && !CmnUtils.isMatch(inclTablesArray,tbName.toUpperCase())){
341- CmnUtils.debugPrint("inclTables=" + inclTables);
342- CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(inclTablesArray,tbName.toUpperCase()));
125+ if(cp.isInclTables && !CmnUtils.isMatch(cp.inclTablesArray,tbName.toUpperCase())){
126+ CmnUtils.debugPrint("cp.inclTables=" + cp.inclTables);
127+ CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(cp.inclTablesArray,tbName.toUpperCase()));
343128 continue;
344129 }
345- if(isExclTables && CmnUtils.isMatch(exclTablesArray,tbName.toUpperCase())){
346- CmnUtils.debugPrint("exclTables=" + exclTables);
347- CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(exclTablesArray,tbName.toUpperCase()));
130+ if(cp.isExclTables && CmnUtils.isMatch(cp.exclTablesArray,tbName.toUpperCase())){
131+ CmnUtils.debugPrint("cp.exclTables=" + cp.exclTables);
132+ CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(cp.exclTablesArray,tbName.toUpperCase()));
348133 continue;
349134 }
350- br = new BufferedReader(new InputStreamReader(new FileInputStream(fldr + "/" + alData.get(i) + "." + flName[1]), fileEncoding));
135+ br = new BufferedReader(new InputStreamReader(new FileInputStream(folder + "/" + alData.get(i) + "." + flName[1]), cp.fileEncoding));
351136 sql_load = "select * from " + alData.get(i);
352137 stmt = dao.prepareSql(sql_load);
353138 dao.executeSql(stmt);
@@ -375,10 +160,10 @@ public class RapideLoader{
375160 CmnUtils.debugPrint("LOB="+isLob);
376161 while((strLine=br.readLine()) != null){
377162 if (fl_rec_count == 0){
378- if(isQuotation){
379- colData = CmnUtils.split(strLine,"\"" + delimiter + "\"");
163+ if(cp.isQuotation){
164+ colData = CmnUtils.split(strLine,"\"" + cp.delimiter + "\"");
380165 } else {
381- colData = CmnUtils.split(strLine,delimiter);
166+ colData = CmnUtils.split(strLine,cp.delimiter);
382167 }
383168 fl_col_count = colData.length;
384169 fl_col_seq = new int[colData.length];
@@ -387,20 +172,20 @@ public class RapideLoader{
387172 for(int j=0;j<colData.length;j++){
388173 for(int l=0;l<tb_col_count;l++){
389174 if(colName[l].equals(colData[j].replaceAll("\"",""))){
390- if(isInclCols || isExclCols){
175+ if(cp.isInclCols || cp.isExclCols){
391176 if(
392- (isInclCols &&
393- !isExclCols &&
394- CmnUtils.isMatch(inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
177+ (cp.isInclCols &&
178+ !cp.isExclCols &&
179+ CmnUtils.isMatch(cp.inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
395180 ) ||
396- (isInclCols &&
397- isExclCols &&
398- CmnUtils.isMatch(inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase()) &&
399- !CmnUtils.isMatch(exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
181+ (cp.isInclCols &&
182+ cp.isExclCols &&
183+ CmnUtils.isMatch(cp.inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase()) &&
184+ !CmnUtils.isMatch(cp.exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
400185 ) ||
401- (!isInclCols &&
402- isExclCols &&
403- !CmnUtils.isMatch(exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
186+ (!cp.isInclCols &&
187+ cp.isExclCols &&
188+ !CmnUtils.isMatch(cp.exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase())
404189 )
405190 ){
406191 CmnUtils.debugPrint("対象カラム=" + colName[l].toUpperCase());
@@ -464,10 +249,10 @@ public class RapideLoader{
464249 break TABLE_LOOP;
465250 }
466251 } else {
467- if(isQuotation){
468- colData = CmnUtils.split(strLine,"\"" + delimiter + "\"");
252+ if(cp.isQuotation){
253+ colData = CmnUtils.split(strLine,"\"" + cp.delimiter + "\"");
469254 } else {
470- colData = CmnUtils.split(strLine,delimiter);
255+ colData = CmnUtils.split(strLine,cp.delimiter);
471256 }
472257 if(colData.length == fl_col_count){
473258 if(!strMltLine.equals("")){
@@ -491,11 +276,11 @@ public class RapideLoader{
491276 strMltLine += strLine;
492277 isContinue = true;
493278 } else {
494- strMltLine += inColLineSeparator + strLine;
495- if(isQuotation){
496- colData = CmnUtils.split(strMltLine,"\"" + delimiter + "\"");
279+ strMltLine += cp.inColLineSeparator + strLine;
280+ if(cp.isQuotation){
281+ colData = CmnUtils.split(strMltLine,"\"" + cp.delimiter + "\"");
497282 } else {
498- colData = CmnUtils.split(strMltLine,delimiter);
283+ colData = CmnUtils.split(strMltLine,cp.delimiter);
499284 }
500285 if(colData.length == fl_col_count){
501286 isContinue = false;
@@ -520,45 +305,45 @@ public class RapideLoader{
520305 if(isContinue == false){
521306 for(int j=0;j<ins_rec_count;j++){
522307 if(j==0){
523- if(isQuotation){
308+ if(cp.isQuotation){
524309 colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(1,colData[fl_col_seq[j]].length());
525310 }
526311 }
527312 if(j==ins_rec_count-1){
528- if(isQuotation){
313+ if(cp.isQuotation){
529314 colData[fl_col_seq[j]]=colData[fl_col_seq[j]].substring(0,colData[fl_col_seq[j]].length()-1);
530315 }
531316 }
532317 if (CmnUtils.isColString(colTypeName[tb_col_seq[j]])){
533- if(isMask){
318+ if(cp.isMask){
534319 if(
535- (isInclColsMask &&
536- !isExclColsMask &&
537- CmnUtils.isMatch(inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase())
320+ (cp.isInclColsMask &&
321+ !cp.isExclColsMask &&
322+ CmnUtils.isMatch(cp.inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase())
538323 ) ||
539- (isInclColsMask &&
540- isExclColsMask &&
541- CmnUtils.isMatch(inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) &&
542- !CmnUtils.isMatch(exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
324+ (cp.isInclColsMask &&
325+ cp.isExclColsMask &&
326+ CmnUtils.isMatch(cp.inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) &&
327+ !CmnUtils.isMatch(cp.exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
543328 ) ||
544- (!isInclColsMask &&
545- isExclColsMask &&
546- !CmnUtils.isMatch(exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
329+ (!cp.isInclColsMask &&
330+ cp.isExclColsMask &&
331+ !CmnUtils.isMatch(cp.exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase())
547332 )
548333 ){
549334 StringBuffer sb = new StringBuffer();
550335 for(int l=0;l<colData[fl_col_seq[j]].length();l++){
551- if((maskPattern.toUpperCase().equals(MASK_PTN[MASK_PTN_ALT]) &&
336+ if((cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALT]) &&
552337 (l % 2) == 1) ||
553- (maskPattern.toUpperCase().equals(MASK_PTN[MASK_PTN_EDGE]) &&
338+ (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_EDGE]) &&
554339 !(l == 0 || j == colData[fl_col_seq[j]].length() - 1) ||
555- (maskPattern.toUpperCase().equals(MASK_PTN[MASK_PTN_ALL]))
340+ (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALL]))
556341 )
557342 ){
558343 if(CmnUtils.isHankaku(colData[fl_col_seq[j]].charAt(l))){
559- sb.append(singleByteMaskChar);
344+ sb.append(cp.singleByteMaskChar);
560345 } else {
561- sb.append(doubleByteMaskChar);
346+ sb.append(cp.doubleByteMaskChar);
562347 }
563348 } else {
564349 sb.append(colData[fl_col_seq[j]].charAt(l));
@@ -568,7 +353,7 @@ public class RapideLoader{
568353 }
569354 }
570355 if (!colData[fl_col_seq[j]].equals("")){
571- if(isQuotation){
356+ if(cp.isQuotation){
572357 stmt_ins.setString(j+1,colData[fl_col_seq[j]].replaceAll("\"\"","\""));
573358 } else {
574359 stmt_ins.setString(j+1,colData[fl_col_seq[j]]);
@@ -661,7 +446,7 @@ public class RapideLoader{
661446 }
662447 }
663448 fl_rec_count++;
664- if (fl_rec_count % batchCount == 0){
449+ if (fl_rec_count % cp.batchCount == 0){
665450 if(!isLob)stmt_ins.executeBatch();
666451 CmnUtils.debugPrint("insert record=" + fl_rec_count);
667452 }
@@ -683,8 +468,7 @@ public class RapideLoader{
683468 }
684469 }
685470 } else {
686- CmnUtils.errorPrint("Folder Not Found(" + fldr + ")");
687- throw new Exception("Folder Not Found(" + fldr + ")");
471+ throw new Exception("Folder Not Found(" + folder + ")");
688472 }
689473
690474 dao.disconnect();
--- a/com/rapide_act/RapideUnloader.java
+++ b/com/rapide_act/RapideUnloader.java
@@ -34,7 +34,7 @@ public class RapideUnloader{
3434 private String user = null;
3535 private String pass = null;
3636 private String url = null;
37- private String sql_table_key_list;
37+ private String tkSql;
3838 private static final int DB_TYPE_ORACLE = 0;
3939 private static final int DB_TYPE_SQLSERVER = 1;
4040 private static final int DB_TYPE_DB2 = 2;
@@ -114,7 +114,7 @@ public class RapideUnloader{
114114 private String [] prop_val = new String[KEYS];
115115
116116
117- private static String [] sql_table_key_list_array = {
117+ private static String [] tkSqlArray = {
118118 "select "
119119 + "a.table_name,"
120120 + "d.column_name "
@@ -284,9 +284,9 @@ public class RapideUnloader{
284284
285285 if (dbType != DB_TYPE_UNKNOWN){
286286 if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL])){
287- sql_table_key_list = prop_val[D_TBLKEYSQL];
287+ tkSql = prop_val[D_TBLKEYSQL];
288288 } else {
289- sql_table_key_list = sql_table_key_list_array[dbType];
289+ tkSql = tkSqlArray[dbType];
290290 }
291291 } else {
292292 throw new Exception("dbtype unknown");
@@ -329,7 +329,7 @@ public class RapideUnloader{
329329 }
330330 CmnUtils.infoPrint("Start DataUnload ---------------------------------------------");
331331
332- dao.select(sql_table_key_list);
332+ dao.select(tkSql);
333333 alData = dao.getArrayList();
334334 tb_count = dao.getColumnCount();
335335 orders = 0;
Show on old repository browser