1 package com.rapide_act;
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;
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;
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;
30 public class CmnProps{
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_MYSQL = 2;
35 protected static final int DB_TYPE_DB2 = 3;
36 protected static final int DB_TYPE_POSTGRESQL = 4;
37 protected static final int DB_TYPE_HIRDB = 5;
38 protected static final int DB_TYPE_UNKNOWN = -1;
39 protected static final String [] DB_TYPE_NAME = {
47 protected static final String [] DB_SQL_QUOTEDS = {
55 protected static final String [] DB_SQL_QUOTEDE = {
63 protected static final String [] SQL_TERMINATOR = {
64 ";" + System.getProperty("line.separator"),
65 System.getProperty("line.separator") + "GO" + System.getProperty("line.separator"),
66 ";" + System.getProperty("line.separator"),
67 ";" + System.getProperty("line.separator"),
68 ";" + System.getProperty("line.separator"),
69 ";" + System.getProperty("line.separator")
71 protected static final String [] SQL_TERMINATOR2 = {
73 System.getProperty("line.separator") + "GO",
79 protected static final String [] SQL_PREFIX = {
87 protected static final String [] SQL_COMMENT_MARK = {
95 protected static final String [] DROP_OPTION = {
96 " CASCADE CONSTRAINT PURGE",
103 protected static final int MASK_PTN_ALL = 0;
104 protected static final int MASK_PTN_ALT = 1;
105 protected static final int MASK_PTN_EDGE = 2;
106 protected static final int D_USER = 0;
107 protected static final int D_PASS = 1;
108 protected static final int D_URL = 2;
109 protected static final int D_DRIVER = 3;
110 protected static final int D_OUTPUT = 4;
111 protected static final int D_INPUT = 5;
112 protected static final int D_LINESEP = 6;
113 protected static final int D_INLINESEP = 7;
114 protected static final int D_FILENCODE = 8;
115 protected static final int D_NULLMARK = 9;
116 protected static final int D_DELIMITER = 10;
117 protected static final int D_TBLSQL = 11;
118 protected static final int D_TBLKEYSQL = 12;
119 protected static final int D_ORDER = 13;
120 protected static final int D_QUOTATION = 14;
121 protected static final int D_BATCOUNT = 15;
122 protected static final int D_INCLTAB = 16;
123 protected static final int D_EXCLTAB = 17;
124 protected static final int D_INCLCOL = 18;
125 protected static final int D_EXCLCOL = 19;
126 protected static final int D_INCLCOLMASK = 20;
127 protected static final int D_EXCLCOLMASK = 21;
128 protected static final int D_SBYTEMASKCHR = 22;
129 protected static final int D_DBYTEMASKCHR = 23;
130 protected static final int D_MASKPTN = 24;
131 protected static final int D_PROPFILE = 25;
132 protected static final int D_SPCPADDING = 26;
133 protected static final int D_FILEEXT = 27;
134 protected static final int D_SQLQUOTEDS = 28;
135 protected static final int D_SQLQUOTEDE = 29;
136 protected static final int D_PHYSICAL = 30;
137 protected static final int D_DROP = 31;
138 protected static final int D_METAFOLDER = 32;
139 protected static final int KEYS = 33;
140 protected static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm",
141 "dm","ts","tks","od","qt","bc","it","et","ic","ec",
142 "icm","ecm","smc","dmc","mp","pf","sp","ext","sqs","sqe",
145 protected String [] prop_val = new String[KEYS];
146 protected static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
147 protected static final String DEFAULT_IN_FOLDER = "input";
148 protected static final String DEFAULT_OUT_FOLDER = "output";
149 protected static final String DEFAULT_PROP_FILE = "RapideAct.properties";
151 protected static final int CREATE_TABLE = 0;
152 protected static final int DROP_TABLE = 1;
153 protected static final int TRUNCATE_TABLE = 2;
154 protected static final int CREATE_PKEY = 3;
155 protected static final int DROP_PKEY = 4;
156 protected static final int CREATE_UKEY = 5;
157 protected static final int DROP_UKEY = 6;
158 protected static final int CREATE_INDEX = 7;
159 protected static final int DROP_INDEX = 8;
160 protected static final int CREATE_VIEW = 9;
161 protected static final int DROP_VIEW = 10;
162 protected static final int CREATE_PROCEDURE = 11;
163 protected static final int DROP_PROCEDURE = 12;
164 protected static final int CREATE_SYNONYM = 13;
165 protected static final int DROP_SYNONYM = 14;
166 protected static final int CREATE_SEQUENCE = 15;
167 protected static final int DROP_SEQUENCE = 16;
168 protected static final int CREATE_FK = 17;
169 protected static final int DROP_FK = 18;
170 protected static final int TYPE_TABLE = 0;
171 protected static final int TYPE_INDEX = 1;
172 protected static final int TYPE_VIEW = 2;
173 protected static final int TYPE_PROCEDURE = 3;
174 protected static final int TYPE_SEQ = 4;
175 protected static final int TYPE_SYNONYM = 5;
176 protected static final int TYPE_OBJ = 6;
177 protected static final int TYPE_FK = 7;
178 protected static final String [] WK_FILE_NAME = {
189 protected static final String [] SQL_FILE_NAME = {
193 "createPrimaryKey.sql",
194 "dropPrimaryKey.sql",
195 "createUniqueKey.sql",
201 "createProcedure.sql",
205 "createSequence.sql",
211 protected static final String [] T_SQL_ARRAY = {
214 + " from user_tables "
215 + " order by table_name",
217 + " name as table_name "
218 + " from sys.tables "
222 + " from information_schema.tables "
223 + " where table_type = 'BASE TABLE' and table_schema = database() "
224 + " order by table_name",
227 + " from syscat.tables "
228 + " where tabschema = current_schema and ownertype = 'U' and type = 'T' "
229 + " order by tabname",
232 + " from information_schema.tables "
233 + " where table_type = 'BASE TABLE' and table_schema = current_schema() "
234 + " order by table_name",
237 + " from master.sql_tables "
238 + " where table_type = 'BASE TABLE' and table_schema=current_user "
239 + " order by table_name"
241 protected static final String [] TK_SQL_ARRAY = {
245 + " from user_tables a,"
246 + " (select b.table_name, "
249 + " from user_constraints b, "
250 + " user_cons_columns c "
251 + " where b.constraint_type = 'P' and "
252 + " b.table_name = c.table_name and "
253 + " b.constraint_name = c.constraint_name "
255 + "where a.table_name = d.table_name(+) "
256 + "order by a.table_name, d.position",
258 + " a.name as table_name, "
259 + " d.name as col_name "
260 + "from sys.tables as a "
261 + "left outer join sys.key_constraints as b "
262 + "on a.object_id = b.parent_object_id "
263 + " and b.type = 'PK' "
264 + "left outer join sys.index_columns as c "
265 + "on b.parent_object_id = c.object_id "
266 + " and b.unique_index_id = c.index_id "
267 + "left outer join sys.columns as d "
268 + "on c.object_id = d.object_id "
269 + " and c.column_id = d.column_id "
270 + "order by a.name,c.key_ordinal",
280 + " information_schema.tables "
281 + " where table_type = 'BASE TABLE' and table_schema = database()"
283 + " left outer join information_schema.key_column_usage b "
284 + " on a.table_schema = b.table_schema "
285 + " and a.table_name = b.table_name "
286 + " and b.constraint_name = 'PRIMARY' "
288 + " a.table_name,b.ordinal_position",
300 + " tabschema = current_schema"
301 + " and ownertype = 'U'"
304 + " left outer join "
312 + " syscat.keycoluse c,"
313 + " syscat.tabconst d"
315 + " c.tabschema = current_schema"
316 + " and c.tabschema = d.tabschema"
317 + " and c.constname = d.constname"
318 + " and d.type = 'P'"
319 + " group by c.tabschema,c.tabname,c.colname,c.colseq"
321 + " on a.tabschema = b.tabschema and a.tabname = b.tabname"
322 + " order by a.tabname,b.colseq",
332 + " information_schema.tables a"
333 + " where table_type = 'BASE TABLE' and table_schema = current_schema()"
335 + " left outer join "
338 + " b1.table_schema,"
341 + " b2.ordinal_position"
343 + " information_schema.table_constraints b1,"
344 + " information_schema.key_column_usage b2"
346 + " b1.table_schema = current_schema() and"
347 + " b1.table_catalog = current_database() and"
348 + " b1.constraint_type = 'PRIMARY KEY' and"
349 + " b1.table_catalog = b2.table_catalog and"
350 + " b1.table_schema = b2.table_schema and"
351 + " b1.table_name = b2.table_name and"
352 + " b1.constraint_name = b2.constraint_name"
354 + " on a.table_schema = b.table_schema "
355 + " and a.table_name = b.table_name "
357 + " a.table_name,b.ordinal_position",
366 + " master.sql_tables a1 "
368 + " a1.table_schema=current_user and "
369 + " a1.table_type='BASE TABLE' "
378 + " master.sql_tables c, "
379 + " master.sql_columns d "
381 + " c.table_schema=current_user and "
382 + " c.table_type='BASE TABLE' and "
383 + " c.table_schema=d.table_schema and "
384 + " c.table_name=d.table_name and "
385 + " d.cluster_key = 'Y' "
392 + " a.table_name=b.table_name "
397 protected static final String [][] meta_sql = {
400 + "a.table_name as table_name,"
401 + "replace(replace(b.comments, chr(13), ''), chr(10), '') as table_comments,"
402 + "c.column_name as column_name, "
403 + "replace(replace(d.comments, chr(13), ''), chr(10), '') as column_comments, "
404 + "decode(c.data_type, 'TIMESTAMP(6)', 'TIMESTAMP',c.data_type) as data_type, "
405 + "c.data_length as data_length,"
406 + "c.data_precision as data_precision,"
407 + "c.data_scale as data_scale,"
408 + "decode(c.nullable, 'N', '
\81\9b', null) as nullable,"
409 + "c.data_default as data_default "
410 + "from user_tables a "
411 + "inner join user_tab_comments b "
412 + "on a.table_name = b.table_name "
413 + "inner join user_tab_columns c "
414 + "on a.table_name = c.table_name "
415 + "inner join user_col_comments d "
416 + "on c.table_name = d.table_name "
417 + " and c.column_name = d.column_name "
418 + "order by a.table_name,c.column_id",
423 + " c.constraint_type,"
425 + " b.column_position "
428 + " user_ind_columns b,"
429 + " user_constraints c "
431 + " a.table_name = b.table_name and"
432 + " a.index_name = b.index_name and"
433 + " a.table_name = c.table_name(+) and"
434 + " a.index_name = c.constraint_name(+) "
438 + " b.column_position",
441 + " replace(replace(c.comments, chr(13), ''), chr(10), '') as comments "
444 + " user_tab_comments c "
446 + " a.view_name = c.table_name(+) "
454 + " where object_type in('PACKAGE BODY','PROCEDURE','FUNCTION','TRIGGER','TYPE')"
455 + " group by object_name,object_type"
456 + " order by object_name,object_type",
459 + " to_char(min_value) as min_value,"
460 + " to_char(max_value) as max_value,"
461 + " to_char(increment_by) as increment_by,"
464 + " to_char(cache_size) as cache_size,"
465 + " to_char(last_number) as last_number "
466 + " from user_sequences "
467 + " order by sequence_name",
473 + "from user_synonyms "
474 + "order by synonym_name,table_owner,table_name",
483 + " a.freelist_groups,"
485 + " a.tablespace_name, "
491 + " table_name as object_name,"
492 + " 'TABLE' as object_type,"
497 + " freelist_groups,"
499 + " tablespace_name, "
505 + " index_name as object_name,"
506 + " 'INDEX' as object_type,"
508 + " null as pct_used,"
511 + " freelist_groups,"
513 + " tablespace_name, "
525 + " where a.object_name = b.segment_name "
526 + " and a.object_type = b.segment_type "
531 + " a.table_name as table_name, "
532 + " a.constraint_name as constraint_name, "
533 + " b.column_name as column_name, "
534 + " b.position as position,"
535 + " c.table_name as r_table_name, "
536 + " d.column_name as r_column_name, "
537 + " d.position as r_position "
539 + " user_constraints a, "
540 + " user_cons_columns b,"
541 + " user_constraints c, "
542 + " user_cons_columns d "
544 + " a.constraint_type = 'R'"
545 + " and a.owner = b.owner"
546 + " and a.table_name = b.table_name"
547 + " and a.constraint_name = b.constraint_name"
548 + " and c.constraint_type in('P','U')"
549 + " and c.owner = b.owner"
550 + " and c.table_name = d.table_name"
551 + " and c.constraint_name = d.constraint_name"
552 + " and a.r_owner = c.owner"
553 + " and a.r_constraint_name = c.constraint_name"
555 + " a.table_name,a.constraint_name,b.position,d.position"
559 + "a.name as table_name, "
560 + "replace(replace(cast(b.value as varchar(4000)), char(13), ''), char(10), '') as table_comments, "
561 + "c.name as column_name, "
562 + "replace(replace(cast(d.value as varchar(4000)), char(13), ''), char(10), '') as column_comments, "
563 + "e.name as data_type, "
564 + "c.max_length as data_length, "
565 + "c.precision as data_precision, "
566 + "c.scale as data_scale, "
567 + "case c.is_nullable"
568 + " when '0' then '
\81Z'"
571 + "g.definition as data_default "
574 + "left outer join sys.extended_properties as b "
575 + "on a.object_id = b.major_id and b.minor_id = 0 "
576 + "inner join sys.columns as c "
577 + "on a.object_id = c.object_id "
578 + "left outer join sys.extended_properties as d "
579 + "on a.object_id = d.major_id and c.column_id = d.minor_id "
580 + "inner join sys.types as e "
581 + "on c.system_type_id = e.system_type_id and c.user_type_id = e.user_type_id "
582 + "left outer join sys.sysconstraints f "
583 + "on c.object_id = f.id "
584 + "and c.column_id = f.colid "
585 + "and (f.status & 2069) = 2069 "
586 + "left outer join sys.default_constraints g "
587 + "on f.constid = g.object_id "
588 + "and a.schema_id = g.schema_id "
589 + "order by a.name,c.column_id ",
591 + "d.name as table_name, "
592 + "a.name as index_name, "
593 + "a.type as index_type, "
594 + "case a.is_unique "
596 + " case a.is_primary_key "
597 + " when 1 then 'P' "
599 + " case a.is_unique_constraint "
600 + " when 1 then 'U' "
605 + "end as constraint_type, "
606 + "c.name as column_name, "
607 + "b.key_ordinal as column_position "
609 + " sys.indexes as a "
610 + " inner join sys.index_columns as b "
611 + " on a.object_id = b.object_id and a.index_id = b.index_id "
612 + " inner join sys.columns as c "
613 + " on c.column_id = b.column_id "
614 + " and c.object_id = b.object_id "
615 + " inner join sys.objects as d "
616 + " on a.object_id = d.object_id and d.type = 'U' "
617 + "order by d.name, a.name,b.key_ordinal",
619 + " a.name as view_name, "
620 + " replace(replace(cast(b.value as varchar(4000)), char(13), ''), char(10), '') as comments "
623 + " left outer join sys.extended_properties as b "
624 + " on a.object_id = b.major_id and b.minor_id = 0 "
628 + " name as object_name, 'PROCEDURE' as object_type from sys.procedures"
630 + " name as object_name, 'FUNCTION' as object_type from sys.objects where type in('FN', 'FS', 'FT', 'IF', 'TF') "
632 + " name as object_name, 'TRIGGER' as object_type from sys.triggers "
633 + " order by object_name,object_type ",
635 + " name as sequence_name,"
636 + " cast(minimum_value as varchar(20)) as min_value,"
637 + " cast(maximum_value as varchar(20)) as max_value,"
638 + " cast(increment as varchar(20)) as increment_by,"
639 + " is_cycling as cycle_flag,"
640 + " is_cached as order_flag,"
641 + " cast(cache_size as varchar(20)) as cache_size,"
642 + " cast(start_value as varchar(20)) as last_number "
643 + " from sys.sequences "
646 + " a.name as synonym_name,"
647 + " b.name as table_owner,"
648 + " base_object_name as table_name,"
650 + "from sys.synonyms a "
651 + " inner join sys.schemas as b "
652 + " on a.schema_id = b.schema_id "
653 + "order by synonym_name,table_owner,table_name",
656 + " c.name as table_name, "
657 + " a.name as constraint_name, "
658 + " d.name as column_name, "
659 + " b.constraint_column_id as position, "
660 + " e.name as r_table_name, "
661 + " f.name as r_column_name ,"
662 + " f.column_id as r_position "
663 + "from sys.foreign_keys as a "
664 + " inner join sys.foreign_key_columns as b "
665 + " on a.object_id = b.constraint_object_id "
666 + " inner join sys.tables as c "
667 + " on b.parent_object_id = c.object_id "
668 + " inner join sys.columns as d "
669 + " on b.parent_object_id = d.object_id and "
670 + " b.parent_column_id = d.column_id "
671 + " inner join sys.tables as e "
672 + " on b.referenced_object_id = e.object_id "
673 + " inner join sys.columns as f "
674 + " on b.referenced_object_id = f.object_id and "
675 + " b.referenced_column_id = f.column_id "
676 + " inner join sys.key_constraints as g "
677 + " on a.referenced_object_id = g.parent_object_id "
678 + "order by table_name,constraint_name, position"
683 + " replace(replace(a.table_comment, char(13), ''), char(10), '') as table_comments, "
685 + " replace(replace(b.column_comment, char(13), ''), char(10), '') as column_comment, "
687 + " b.character_maximum_length as data_precision,"
688 + " b.numeric_precision as data_precision,"
689 + " b.numeric_scale as data_scale,"
690 + " case b.is_nullable"
691 + " when 'NO' then '
\81Z'"
693 + " end as nullable,"
694 + " column_default as data_default "
696 + " information_schema.tables a,"
697 + " information_schema.columns b "
699 + " a.table_schema = database()"
700 + " and a.table_type = 'BASE TABLE'"
701 + " and a.table_schema = b.table_schema "
702 + " and a.table_name = b.table_name "
703 + "order by a.table_name,b.ordinal_position",
706 + " b.constraint_name as index_name,"
707 + " '' as index_type, "
708 + " case b.constraint_type "
709 + " when 'PRIMARY KEY' then 'P' "
710 + " when 'UNIQUE' then 'U' "
711 + " end as constraint_type,"
713 + " c.ordinal_position as column_position"
715 + " information_schema.tables a,"
716 + " information_schema.table_constraints b,"
717 + " information_schema.key_column_usage c"
719 + " a.table_schema = database()"
720 + " and a.table_type = 'BASE TABLE'"
721 + " and a.table_schema = b.table_schema"
722 + " and a.table_name = b.table_name"
723 + " and b.table_schema = c.table_schema"
724 + " and b.table_name = c.table_name"
725 + " and b.constraint_name = c.constraint_name"
726 + " and b.constraint_type in('PRIMARY KEY','UNIQUE')"
730 + " b.index_type as index_type, "
731 + " '' as constraint_type,"
733 + " a.seq_in_index as column_position"
735 + " information_schema.statistics a,"
736 + " information_schema.statistics b"
738 + " a.table_schema = database()"
739 + " and a.table_schema = b.table_schema"
740 + " and a.table_name = b.table_name"
741 + " and a.index_name = b.index_name"
742 + " and a.non_unique = 1"
743 + " order by table_name,index_name,column_position",
745 + " a.table_name as view_name, "
748 + " information_schema.views a "
750 + " table_schema = database()"
754 + " routine_name as object_name, "
755 + " routine_type as object_type, "
756 + " '' as action_timing, "
757 + " '' as event_action, "
758 + " '' as event_object "
760 + " information_schema.routines "
762 + " routine_schema = database()"
763 + " and (routine_type = 'PROCEDURE' or routine_type = 'FUNCTION') "
765 + " trigger_name as object_name, "
766 + " 'TRIGGER' as object_type, "
767 + " action_timing as action_timing, "
768 + " event_manipulation as event_action, "
769 + " event_object_table as event_object "
771 + " information_schema.triggers "
773 + " trigger_schema = database()"
774 + " order by object_name,object_type ",
780 + " b.constraint_name, "
782 + " b.ordinal_position as position, "
783 + " b.referenced_table_name as r_table_name, "
784 + " b.referenced_column_name as r_column_name, "
785 + " c.ordinal_position as r_position "
787 + " information_schema.referential_constraints a, "
788 + " information_schema.key_column_usage b, "
789 + " information_schema.columns c "
791 + " a.constraint_schema = database() "
792 + " and a.constraint_schema = b.constraint_schema "
793 + " and a.constraint_name = b.constraint_name "
794 + " and b.referenced_table_name = c.table_name "
795 + " and b.referenced_column_name = c.column_name "
798 protected static String sql_view_text[] = {
799 "select text from user_views where view_name = ?",
800 "select c.definition "
801 + "from sys.views a "
802 + "inner join sys.objects b "
803 + "on b.object_id = a.object_id "
804 + "inner join sys.sql_modules c "
805 + "on c.object_id = b.object_id "
806 + "where a.name = ?",
807 "select view_definition from information_schema.views where table_name = ?"
809 protected static String sql_view_column_and_comment[] = {
812 + " replace(replace(d.comments, chr(13), ''), chr(10), '') as comments "
814 + " user_tab_columns b,"
815 + " user_col_comments d "
817 + " b.table_name = ? and"
818 + " b.table_name = d.table_name(+) and"
819 + " b.column_name = d.column_name(+) "
823 + " b.name as column_name, "
827 + " inner join sys.columns b on a.object_id = b.object_id and a.name = ? "
828 + " inner join sys.types c on b.system_type_id = c.system_type_id "
829 + " where a.type = 'V' "
830 + " and c.user_type_id <> 256 "
831 + " order by b.column_id",
834 + " replace(replace(column_comment, char(13), ''), char(10), '') as column_comment "
836 + " information_schema.columns "
839 + " order by ordinal_position"
841 protected static String sql_proc[] = {
842 "select text from user_source where type = ? and name = ? order by line",
843 "select d.definition "
845 + " (select a.name,'PROCEDURE' as type,c.definition "
846 + "from sys.procedures a "
847 + "inner join sys.objects b "
848 + "on b.object_id = a.object_id "
849 + "inner join sys.sql_modules c "
850 + "on c.object_id = b.object_id "
852 + " a.name,'FUNCTION' as type,c.definition "
853 + "from sys.objects a "
854 + "inner join sys.objects b "
855 + "on b.object_id = a.object_id "
856 + "inner join sys.sql_modules c "
857 + "on c.object_id = b.object_id and a.type in('FN', 'FS', 'FT', 'IF', 'TF') "
859 + "a.name,'TRIGGER' as type,c.definition "
860 + "from sys.triggers a "
861 + "inner join sys.objects b "
862 + "on b.object_id = a.object_id "
863 + "inner join sys.sql_modules c "
864 + "on c.object_id = b.object_id) d "
865 + "where d.type = ? and d.name = ?",
866 "select a.definition "
870 + " routine_name as object_name, "
871 + " routine_type as object_type, "
872 + " routine_definition as definition "
874 + " information_schema.routines "
876 + " routine_schema = database() "
878 + " trigger_name as object_name, "
879 + " 'TRIGGER' as object_type, "
880 + " action_statement as definition "
882 + " information_schema.triggers "
884 + " trigger_schema = database() "
887 + " a.object_type = ? "
888 + " and a.object_name = ? "
891 protected String user = null;
892 protected String pass = null;
893 protected String url = null;
894 protected String driver = null;
895 protected String outFolder = null;
896 protected String inFolder = null;
897 protected String lineSeparator = System.getProperty("line.separator");
898 protected String inColLineSeparator = System.getProperty("line.separator");
899 protected String fileEncoding = System.getProperty("file.encoding");
900 protected String nullMark = "";
901 protected String delimiter = "\t";
902 protected String fileExtension = "tsv";
903 protected boolean isSpcPadding = false;
904 protected String sqlQuotedS = null;
905 protected String sqlQuotedE = null;
906 protected String tSql = null;
907 protected String tkSql = null;
908 protected boolean isOrder = false;
909 protected boolean isQuotation = true;
910 protected boolean isPhysical = false;
911 protected boolean isDrop = false;
912 protected int batchCount = 1000;
913 protected String inclTables = null;
914 protected String exclTables = null;
915 protected String inclCols = null;
916 protected String exclCols = null;
917 protected String inclColsMask = null;
918 protected String exclColsMask = null;
919 protected char singleByteMaskChar = '*';
920 protected char doubleByteMaskChar = '\u25A0';
921 protected String maskPattern = "ALT";
922 protected String metaFolder = "DDL";
924 protected String [] inclTablesArray = null;
925 protected String [] exclTablesArray = null;
926 protected String [] inclColsArray = null;
927 protected String [] exclColsArray = null;
928 protected String [] inclColsMaskArray = null;
929 protected String [] exclColsMaskArray = null;
930 protected boolean isInclTables = false;
931 protected boolean isExclTables = false;
932 protected boolean isInclCols = false;
933 protected boolean isExclCols = false;
934 protected boolean isMask = false;
935 protected boolean isInclColsMask = false;
936 protected boolean isExclColsMask = false;
937 protected int dbType = DB_TYPE_UNKNOWN;
939 protected void getProperties(String _propFile) throws Exception{
940 BufferedReader br = null;
941 Properties prop = null;
943 prop = new Properties();
944 br = new BufferedReader(new InputStreamReader(CmnProps.class.getClassLoader().getResourceAsStream(_propFile), "UTF-8"));
946 for(int i=0;i<KEYS;i++){
947 prop_val[i] = prop.getProperty(database + "." +PROP_KEY[i]);
951 } catch (NullPointerException e) {
952 throw new Exception("
\83v
\83\8d\83p
\83e
\83B
\83t
\83@
\83C
\83\8b\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ
\81B[" + _propFile +"]");
953 } catch (IOException e) {
963 catch (IOException e) {
974 protected void setProperty(String _database) throws Exception{
975 database = _database;
976 if(database != null){
977 if(!CmnUtils.isEmpty(prop_val[D_PROPFILE])){
978 getProperties(System.getProperty(prop_val[D_PROPFILE]));
980 getProperties(DEFAULT_PROP_FILE);
984 for(int i=0;i<KEYS;i++){
985 if(System.getProperty(PROP_KEY[i])!=null)prop_val[i] = System.getProperty(PROP_KEY[i]);
986 CmnUtils.debugPrint(PROP_KEY[i] + "=" + prop_val[i]);
989 if(!CmnUtils.isEmpty(prop_val[D_USER]))user = prop_val[D_USER];
990 if(!CmnUtils.isEmpty(prop_val[D_PASS]))pass = prop_val[D_PASS];
991 if(!CmnUtils.isEmpty(prop_val[D_URL]))url = prop_val[D_URL];
992 if(!CmnUtils.isEmpty(prop_val[D_DRIVER]))driver = prop_val[D_DRIVER];
993 if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT];
994 if(!CmnUtils.isEmpty(prop_val[D_INPUT]))inFolder = prop_val[D_INPUT];
995 if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]);
996 if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))inColLineSeparator = CmnUtils.getLineSeparator(prop_val[D_INLINESEP]);
997 if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE];
998 if(!CmnUtils.isEmpty(prop_val[D_NULLMARK]))nullMark = prop_val[D_NULLMARK];
999 if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]);
1000 if(!CmnUtils.isEmpty(prop_val[D_TBLSQL]))tSql = prop_val[D_TBLSQL];
1001 if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL]))tkSql = prop_val[D_TBLKEYSQL];
1002 if(!CmnUtils.isEmpty(prop_val[D_ORDER]) && prop_val[D_ORDER].toUpperCase().equals("Y"))isOrder = true;
1003 if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]) && prop_val[D_QUOTATION].toUpperCase().equals("N"))isQuotation = false;
1004 if(!CmnUtils.isEmpty(prop_val[D_PHYSICAL]) && prop_val[D_PHYSICAL].toUpperCase().equals("Y"))isPhysical = true;
1005 if(!CmnUtils.isEmpty(prop_val[D_DROP]) && prop_val[D_DROP].toUpperCase().equals("Y"))isDrop = true;
1006 if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]) && CmnUtils.isNumeric(prop_val[D_BATCOUNT]))batchCount = Integer.parseInt(prop_val[D_BATCOUNT]);
1007 if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))isInclTables = true;
1008 if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))isExclTables = true;
1009 if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))isInclCols = true;
1010 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))isExclCols = true;
1011 if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))isInclColsMask = true;
1012 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))isExclColsMask = true;
1013 if(isInclColsMask || isExclColsMask)isMask = true;
1014 if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTables = prop_val[D_INCLTAB].toUpperCase();
1015 if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTables = prop_val[D_EXCLTAB].toUpperCase();
1016 if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclCols = prop_val[D_INCLCOL].toUpperCase();
1017 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclCols = prop_val[D_EXCLCOL].toUpperCase();
1018 if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMask = prop_val[D_INCLCOLMASK].toUpperCase();
1019 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMask = prop_val[D_EXCLCOLMASK].toUpperCase();
1020 if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTablesArray = CmnUtils.splitCsv(prop_val[D_INCLTAB].toUpperCase());
1021 if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTablesArray = CmnUtils.splitCsv(prop_val[D_EXCLTAB].toUpperCase());
1022 if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclColsArray = CmnUtils.splitCsv(prop_val[D_INCLCOL].toUpperCase());
1023 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclColsArray = CmnUtils.splitCsv(prop_val[D_EXCLCOL].toUpperCase());
1024 if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMaskArray = CmnUtils.splitCsv(prop_val[D_INCLCOLMASK].toUpperCase());
1025 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMaskArray = CmnUtils.splitCsv(prop_val[D_EXCLCOLMASK].toUpperCase());
1026 if(!CmnUtils.isEmpty(prop_val[D_SBYTEMASKCHR]))singleByteMaskChar = prop_val[D_SBYTEMASKCHR].charAt(0);
1027 if(!CmnUtils.isEmpty(prop_val[D_DBYTEMASKCHR]))doubleByteMaskChar = prop_val[D_DBYTEMASKCHR].charAt(0);
1028 if(!CmnUtils.isEmpty(prop_val[D_MASKPTN]))maskPattern = prop_val[D_MASKPTN];
1029 if(!CmnUtils.isEmpty(prop_val[D_METAFOLDER]))metaFolder = prop_val[D_METAFOLDER];
1030 if(!CmnUtils.isEmpty(prop_val[D_SPCPADDING]) && prop_val[D_SPCPADDING].toUpperCase().equals("Y"))isSpcPadding = true;
1031 if(!CmnUtils.isEmpty(prop_val[D_FILEEXT]))fileExtension = prop_val[D_FILEEXT];
1033 if(CmnUtils.isEmpty(user)){
1034 throw new Exception("us(
\83\86\81[
\83UID)
\82ª
\96¢
\8ew
\92è
\82Å
\82·
\81B");
1035 } else if (CmnUtils.isEmpty(pass)){
1036 throw new Exception("pw(
\83p
\83X
\83\8f\81[
\83h)
\82ª
\96¢
\8ew
\92è
\82Å
\82·
\81B");
1037 } else if (CmnUtils.isEmpty(url)){
1038 throw new Exception("url(
\90Ú
\91±
\8fî
\95ñ)
\82ª
\96¢
\8ew
\92è
\82Å
\82·
\81B");
1039 } else if (CmnUtils.isEmpty(driver)){
1040 throw new Exception("dr(
\83h
\83\89\83C
\83o)
\82ª
\96¢
\8ew
\92è
\82Å
\82·
\81B");
1043 for(int i = 0;i<DB_TYPE_NAME.length;i++){
1044 if (url.toUpperCase().contains(DB_TYPE_NAME[i])){
1050 if (dbType != DB_TYPE_UNKNOWN){
1051 if(!CmnUtils.isEmpty(prop_val[D_TBLSQL])){
1052 tSql = prop_val[D_TBLSQL];
1054 tSql = T_SQL_ARRAY[dbType];
1056 if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL])){
1057 tkSql = prop_val[D_TBLKEYSQL];
1059 tkSql = TK_SQL_ARRAY[dbType];
1061 if(!CmnUtils.isEmpty(prop_val[D_SQLQUOTEDS])){
1062 sqlQuotedS = prop_val[D_SQLQUOTEDS];
1064 sqlQuotedS = DB_SQL_QUOTEDS[dbType];
1066 if(!CmnUtils.isEmpty(prop_val[D_SQLQUOTEDE])){
1067 sqlQuotedE = prop_val[D_SQLQUOTEDE];
1069 sqlQuotedE = DB_SQL_QUOTEDE[dbType];
1072 throw new Exception("
\83f
\81[
\83^
\83x
\81[
\83X
\90»
\95i
\82ª
\8e¯
\95Ê
\82Å
\82«
\82Ü
\82¹
\82ñ
\81B[" + url + "]");
1075 if(database!=null)CmnUtils.infoPrint("-->
\91Î
\8fÛ
\83f
\81[
\83^
\83x
\81[
\83X='" + database.toUpperCase() + "'");
1076 if(!CmnUtils.isEmpty(prop_val[D_FILEEXT]))CmnUtils.infoPrint("-->
\83t
\83@
\83C
\83\8b\8ag
\92£
\8eq='" + prop_val[D_FILEEXT] + "'");
1077 if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))CmnUtils.infoPrint("-->
\8bæ
\90Ø
\82è
\95¶
\8e\9a='" + prop_val[D_DELIMITER] + "'");
1078 if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))CmnUtils.infoPrint("-->
\89ü
\8ds
\83R
\81[
\83h='" + prop_val[D_LINESEP] + "'");
1079 if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))CmnUtils.infoPrint("-->
\83J
\83\89\83\80\93à
\89ü
\8ds
\83R
\81[
\83h='" + prop_val[D_INLINESEP] + "'");
1080 if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))CmnUtils.infoPrint("-->
\95¶
\8e\9a\83R
\81[
\83h='" + prop_val[D_FILENCODE] + "'");
1081 if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]))CmnUtils.infoPrint("-->
\88ø
\97p
\8bå=" + CmnUtils.getYesNo(isQuotation));
1082 if(!CmnUtils.isEmpty(prop_val[D_SQLQUOTEDS]) && !CmnUtils.isEmpty(prop_val[D_SQLQUOTEDE]))CmnUtils.infoPrint("-->SQL
\88ø
\97p
\95\84=" + "'" + sqlQuotedS + "' '" + sqlQuotedE + "'");
1083 if(!CmnUtils.isEmpty(prop_val[D_ORDER]))CmnUtils.infoPrint("-->
\83\
\81[
\83g=" + CmnUtils.getYesNo(isOrder));
1084 if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))CmnUtils.infoPrint("-->
\83o
\83b
\83`
\8f\88\97\9d\90\94=" + batchCount);
1085 if(isSpcPadding)CmnUtils.infoPrint("-->
\8bó
\94\92\96\84\82ß=" + CmnUtils.getYesNo(isSpcPadding));
1086 if(isInclTables)CmnUtils.infoPrint("-->
\91Î
\8fÛ
\83e
\81[
\83u
\83\8b='" + inclTables.toUpperCase() + "'");
1087 if(isExclTables)CmnUtils.infoPrint("-->
\8f\9c\8aO
\83e
\81[
\83u
\83\8b='" + exclTables.toUpperCase() + "'");
1088 if(isInclCols)CmnUtils.infoPrint("-->
\91Î
\8fÛ
\83J
\83\89\83\80='" + inclCols.toUpperCase() + "'");
1089 if(isExclCols)CmnUtils.infoPrint("-->
\8f\9c\8aO
\83J
\83\89\83\80='" + exclCols.toUpperCase() + "'");
1091 CmnUtils.infoPrint("-->
\83}
\83X
\83L
\83\93\83O=" + CmnUtils.getYesNo(isMask));
1092 CmnUtils.infoPrint("-->
\83}
\83X
\83N
\83L
\83\93\83O
\83p
\83^
\81[
\83\93=" + maskPattern.toUpperCase());
1093 CmnUtils.infoPrint("-->
\94¼
\8ap
\83}
\83X
\83N
\95¶
\8e\9a='" + singleByteMaskChar + "'");
1094 CmnUtils.infoPrint("-->
\91S
\8ap
\83}
\83X
\83N
\95¶
\8e\9a='" + doubleByteMaskChar + "'");
1095 if(isInclColsMask)CmnUtils.infoPrint("-->
\83}
\83X
\83N
\91Î
\8fÛ
\83J
\83\89\83\80='" + inclColsMask.toUpperCase() + "'");
1096 if(isExclColsMask)CmnUtils.infoPrint("-->
\83}
\83X
\83N
\8f\9c\8aO
\83J
\83\89\83\80='" + exclColsMask.toUpperCase() + "'");