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 = {"ORACLE", "SQLSERVER", "MYSQL", "DB2", "POSTGRESQL", "HIRDB"};
40 protected static final String [] DB_SQL_QUOTEDS = {"\"", "[", "`", "\"", "\"", "\""};
41 protected static final String [] DB_SQL_QUOTEDE = {"\"", "]", "`", "\"", "\"", "\""};
42 protected static final String [] SQL_TERMINATOR = {";" + System.getProperty("line.separator"), System.getProperty("line.separator") + "GO" + System.getProperty("line.separator"), ";" + System.getProperty("line.separator"), ";", ";", ";"};
43 protected static final String [] SQL_PREFIX = {"@", ":r ", "source ", "", "", ""};
44 protected static final String [] SQL_COMMENT_MARK = {"--", "--", "--", "--", "--", "--"};
45 protected static final int MASK_PTN_ALL = 0;
46 protected static final int MASK_PTN_ALT = 1;
47 protected static final int MASK_PTN_EDGE = 2;
48 protected static final int D_USER = 0;
49 protected static final int D_PASS = 1;
50 protected static final int D_URL = 2;
51 protected static final int D_DRIVER = 3;
52 protected static final int D_OUTPUT = 4;
53 protected static final int D_INPUT = 5;
54 protected static final int D_LINESEP = 6;
55 protected static final int D_INLINESEP = 7;
56 protected static final int D_FILENCODE = 8;
57 protected static final int D_NULLMARK = 9;
58 protected static final int D_DELIMITER = 10;
59 protected static final int D_TBLSQL = 11;
60 protected static final int D_TBLKEYSQL = 12;
61 protected static final int D_ORDER = 13;
62 protected static final int D_QUOTATION = 14;
63 protected static final int D_BATCOUNT = 15;
64 protected static final int D_INCLTAB = 16;
65 protected static final int D_EXCLTAB = 17;
66 protected static final int D_INCLCOL = 18;
67 protected static final int D_EXCLCOL = 19;
68 protected static final int D_INCLCOLMASK = 20;
69 protected static final int D_EXCLCOLMASK = 21;
70 protected static final int D_SBYTEMASKCHR = 22;
71 protected static final int D_DBYTEMASKCHR = 23;
72 protected static final int D_MASKPTN = 24;
73 protected static final int D_PROPFILE = 25;
74 protected static final int D_SPCPADDING = 26;
75 protected static final int D_FILEEXT = 27;
76 protected static final int D_SQLQUOTEDS = 28;
77 protected static final int D_SQLQUOTEDE = 29;
78 protected static final int D_PHYSICAL = 30;
79 protected static final int D_DROP = 31;
80 protected static final int D_METAFOLDER = 32;
81 protected static final int KEYS = 33;
82 protected static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm",
83 "dm","ts","tks","od","qt","bc","it","et","ic","ec",
84 "icm","ecm","smc","dmc","mp","pf","sp","ext","sqs","sqe",
87 protected String [] prop_val = new String[KEYS];
88 protected static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
89 protected static final String DEFAULT_IN_FOLDER = "input";
90 protected static final String DEFAULT_OUT_FOLDER = "output";
91 protected static final String DEFAULT_PROP_FILE = "RapideAct.properties";
93 protected static final int CREATE_TABLE = 0;
94 protected static final int DROP_TABLE = 1;
95 protected static final int TRUNCATE_TABLE = 2;
96 protected static final int CREATE_PKEY = 3;
97 protected static final int DROP_PKEY = 4;
98 protected static final int CREATE_UKEY = 5;
99 protected static final int DROP_UKEY = 6;
100 protected static final int CREATE_INDEX = 7;
101 protected static final int DROP_INDEX = 8;
102 protected static final int CREATE_VIEW = 9;
103 protected static final int DROP_VIEW = 10;
104 protected static final int CREATE_PROCEDURE = 11;
105 protected static final int DROP_PROCEDURE = 12;
106 protected static final int CREATE_SYNONYM = 13;
107 protected static final int DROP_SYNONYM = 14;
108 protected static final int CREATE_SEQUENCE = 15;
109 protected static final int DROP_SEQUENCE = 16;
110 protected static final int CREATE_FK = 17;
111 protected static final int DROP_FK = 18;
112 protected static final int TYPE_TABLE = 0;
113 protected static final int TYPE_INDEX = 1;
114 protected static final int TYPE_VIEW = 2;
115 protected static final int TYPE_PROCEDURE = 3;
116 protected static final int TYPE_SEQ = 4;
117 protected static final int TYPE_SYNONYM = 5;
118 protected static final int TYPE_OBJ = 6;
119 protected static final int TYPE_FK = 7;
120 protected static final String [] WK_FILE_NAME = {
130 protected static final String [] DROP_OPTION = {" CASCADE CONSTRAINT PURGE", "", "", "", "", ""};
132 protected static final String [] SQL_FILE_NAME = {
136 "createPrimaryKey.sql",
137 "dropPrimaryKey.sql",
138 "createUniqueKey.sql",
144 "createProcedure.sql",
148 "createSequence.sql",
154 protected static final String [] T_SQL_ARRAY = {
157 + " from user_tables "
158 + " order by table_name",
160 + " name as table_name "
161 + " from sys.tables "
165 + " from information_schema.tables "
166 + " where table_type = 'BASE TABLE' and table_schema = database() "
167 + " order by table_name",
170 + " from syscat.tables "
171 + " where tabschema = current_schema and ownertype = 'U' and type = 'T' "
172 + " order by tabname",
175 + " from information_schema.tables "
176 + " where table_type = 'BASE TABLE' and table_schema = current_schema() "
177 + " order by table_name",
180 + " from master.sql_tables "
181 + " where table_type = 'BASE TABLE' and table_schema=current_user "
182 + " order by table_name"
184 protected static final String [] TK_SQL_ARRAY = {
188 + " from user_tables a,"
189 + " (select b.table_name, "
192 + " from user_constraints b, "
193 + " user_cons_columns c "
194 + " where b.constraint_type = 'P' and "
195 + " b.table_name = c.table_name and "
196 + " b.constraint_name = c.constraint_name "
198 + "where a.table_name = d.table_name(+) "
199 + "order by a.table_name, d.position",
201 + " a.name as table_name, "
202 + " d.name as col_name "
203 + "from sys.tables as a "
204 + "left outer join sys.key_constraints as b "
205 + "on a.object_id = b.parent_object_id "
206 + " and b.type = 'PK' "
207 + "left outer join sys.index_columns as c "
208 + "on b.parent_object_id = c.object_id "
209 + " and b.unique_index_id = c.index_id "
210 + "left outer join sys.columns as d "
211 + "on c.object_id = d.object_id "
212 + " and c.column_id = d.column_id "
213 + "order by a.name,c.key_ordinal",
223 + " information_schema.tables "
224 + " where table_type = 'BASE TABLE' and table_schema = database()"
226 + " left outer join information_schema.key_column_usage b "
227 + " on a.table_schema = b.table_schema "
228 + " and a.table_name = b.table_name "
229 + " and b.constraint_name = 'PRIMARY' "
231 + " a.table_name,b.ordinal_position",
243 + " tabschema = current_schema"
244 + " and ownertype = 'U'"
247 + " left outer join "
255 + " syscat.keycoluse c,"
256 + " syscat.tabconst d"
258 + " c.tabschema = current_schema"
259 + " and c.tabschema = d.tabschema"
260 + " and c.constname = d.constname"
261 + " and d.type = 'P'"
262 + " group by c.tabschema,c.tabname,c.colname,c.colseq"
264 + " on a.tabschema = b.tabschema and a.tabname = b.tabname"
265 + " order by a.tabname,b.colseq",
275 + " information_schema.tables a"
276 + " where table_type = 'BASE TABLE' and table_schema = current_schema()"
278 + " left outer join "
281 + " b1.table_schema,"
284 + " b2.ordinal_position"
286 + " information_schema.table_constraints b1,"
287 + " information_schema.key_column_usage b2"
289 + " b1.table_schema = current_schema() and"
290 + " b1.table_catalog = current_database() and"
291 + " b1.constraint_type = 'PRIMARY KEY' and"
292 + " b1.table_catalog = b2.table_catalog and"
293 + " b1.table_schema = b2.table_schema and"
294 + " b1.table_name = b2.table_name and"
295 + " b1.constraint_name = b2.constraint_name"
297 + " on a.table_schema = b.table_schema "
298 + " and a.table_name = b.table_name "
300 + " a.table_name,b.ordinal_position",
309 + " master.sql_tables a1 "
311 + " a1.table_schema=current_user and "
312 + " a1.table_type='BASE TABLE' "
321 + " master.sql_tables c, "
322 + " master.sql_columns d "
324 + " c.table_schema=current_user and "
325 + " c.table_type='BASE TABLE' and "
326 + " c.table_schema=d.table_schema and "
327 + " c.table_name=d.table_name and "
328 + " d.cluster_key = 'Y' "
335 + " a.table_name=b.table_name "
340 protected static final String [][] meta_sql = {
343 + "a.table_name as table_name,"
344 + "replace(replace(b.comments, chr(13), ''), chr(10), '') as table_comments,"
345 + "c.column_name as column_name, "
346 + "replace(replace(d.comments, chr(13), ''), chr(10), '') as column_comments, "
347 + "decode(c.data_type, 'TIMESTAMP(6)', 'TIMESTAMP',c.data_type) as data_type, "
348 + "c.data_length as data_length,"
349 + "c.data_precision as data_precision,"
350 + "c.data_scale as data_scale,"
351 + "decode(c.nullable, 'N', '
\81\9b', null) as nullable,"
352 + "c.data_default as data_default "
353 + "from user_tables a "
354 + "inner join user_tab_comments b "
355 + "on a.table_name = b.table_name "
356 + "inner join user_tab_columns c "
357 + "on a.table_name = c.table_name "
358 + "inner join user_col_comments d "
359 + "on c.table_name = d.table_name "
360 + " and c.column_name = d.column_name "
361 + "order by a.table_name,c.column_id",
366 + " c.constraint_type,"
368 + " b.column_position "
371 + " user_ind_columns b,"
372 + " user_constraints c "
374 + " a.table_name = b.table_name and"
375 + " a.index_name = b.index_name and"
376 + " a.table_name = c.table_name(+) and"
377 + " a.index_name = c.constraint_name(+) "
381 + " b.column_position",
384 + " replace(replace(c.comments, chr(13), ''), chr(10), '') as comments "
387 + " user_tab_comments c "
389 + " a.view_name = c.table_name(+) "
397 + " where object_type in('PACKAGE BODY','PROCEDURE','FUNCTION','TRIGGER','TYPE')"
398 + " group by object_name,object_type"
399 + " order by object_name,object_type",
402 + " to_char(min_value) as min_value,"
403 + " to_char(max_value) as max_value,"
404 + " to_char(increment_by) as increment_by,"
407 + " to_char(cache_size) as cache_size,"
408 + " to_char(last_number) as last_number "
409 + " from user_sequences "
410 + " order by sequence_name",
416 + "from user_synonyms "
417 + "order by synonym_name,table_owner,table_name",
426 + " a.freelist_groups,"
428 + " a.tablespace_name, "
434 + " table_name as object_name,"
435 + " 'TABLE' as object_type,"
440 + " freelist_groups,"
442 + " tablespace_name, "
448 + " index_name as object_name,"
449 + " 'INDEX' as object_type,"
451 + " null as pct_used,"
454 + " freelist_groups,"
456 + " tablespace_name, "
468 + " where a.object_name = b.segment_name "
469 + " and a.object_type = b.segment_type "
474 + " a.table_name as table_name, "
475 + " a.constraint_name as constraint_name, "
476 + " b.column_name as column_name, "
477 + " b.position as position,"
478 + " c.table_name as r_table_name, "
479 + " d.column_name as r_column_name, "
480 + " d.position as r_position "
482 + " user_constraints a, "
483 + " user_cons_columns b,"
484 + " user_constraints c, "
485 + " user_cons_columns d "
487 + " a.constraint_type = 'R'"
488 + " and a.owner = b.owner"
489 + " and a.table_name = b.table_name"
490 + " and a.constraint_name = b.constraint_name"
491 + " and c.constraint_type in('P','U')"
492 + " and c.owner = b.owner"
493 + " and c.table_name = d.table_name"
494 + " and c.constraint_name = d.constraint_name"
495 + " and a.r_owner = c.owner"
496 + " and a.r_constraint_name = c.constraint_name"
498 + " a.table_name,a.constraint_name,b.position,d.position"
502 + "a.name as table_name, "
503 + "replace(replace(cast(b.value as varchar(4000)), char(13), ''), char(10), '') as table_comments, "
504 + "c.name as column_name, "
505 + "replace(replace(cast(d.value as varchar(4000)), char(13), ''), char(10), '') as column_comments, "
506 + "e.name as data_type, "
507 + "c.max_length as data_length, "
508 + "c.precision as data_precision, "
509 + "c.scale as data_scale, "
510 + "case c.is_nullable"
511 + " when '0' then '
\81Z'"
514 + "g.definition as data_default "
517 + "left outer join sys.extended_properties as b "
518 + "on a.object_id = b.major_id and b.minor_id = 0 "
519 + "inner join sys.columns as c "
520 + "on a.object_id = c.object_id "
521 + "left outer join sys.extended_properties as d "
522 + "on a.object_id = d.major_id and c.column_id = d.minor_id "
523 + "inner join sys.types as e "
524 + "on c.system_type_id = e.system_type_id and c.user_type_id = e.user_type_id "
525 + "left outer join sys.sysconstraints f "
526 + "on c.object_id = f.id "
527 + "and c.column_id = f.colid "
528 + "and (f.status & 2069) = 2069 "
529 + "left outer join sys.default_constraints g "
530 + "on f.constid = g.object_id "
531 + "and a.schema_id = g.schema_id "
532 + "order by a.name,c.column_id ",
534 + "d.name as table_name, "
535 + "a.name as index_name, "
536 + "a.type as index_type, "
537 + "case a.is_unique "
539 + " case a.is_primary_key "
540 + " when 1 then 'P' "
542 + " case a.is_unique_constraint "
543 + " when 1 then 'U' "
548 + "end as constraint_type, "
549 + "c.name as column_name, "
550 + "b.key_ordinal as column_position "
552 + " sys.indexes as a "
553 + " inner join sys.index_columns as b "
554 + " on a.object_id = b.object_id and a.index_id = b.index_id "
555 + " inner join sys.columns as c "
556 + " on c.column_id = b.column_id "
557 + " and c.object_id = b.object_id "
558 + " inner join sys.objects as d "
559 + " on a.object_id = d.object_id and d.type = 'U' "
560 + "order by d.name, a.name,b.key_ordinal",
562 + " a.name as view_name, "
563 + " replace(replace(cast(b.value as varchar(4000)), char(13), ''), char(10), '') as comments "
566 + " left outer join sys.extended_properties as b "
567 + " on a.object_id = b.major_id and b.minor_id = 0 "
571 + " name as object_name, 'PROCEDURE' as object_type from sys.procedures"
573 + " name as object_name, 'FUNCTION' as object_type from sys.objects where type in('FN', 'FS', 'FT', 'IF', 'TF') "
575 + " name as object_name, 'TRIGGER' as object_type from sys.triggers "
576 + " order by object_name,object_type ",
578 + " name as sequence_name,"
579 + " cast(minimum_value as varchar(20)) as min_value,"
580 + " cast(maximum_value as varchar(20)) as max_value,"
581 + " cast(increment as varchar(20)) as increment_by,"
582 + " is_cycling as cycle_flag,"
583 + " is_cached as order_flag,"
584 + " cast(cache_size as varchar(20)) as cache_size,"
585 + " cast(start_value as varchar(20)) as last_number "
586 + " from sys.sequences "
589 + " a.name as synonym_name,"
590 + " b.name as table_owner,"
591 + " base_object_name as table_name,"
593 + "from sys.synonyms a "
594 + " inner join sys.schemas as b "
595 + " on a.schema_id = b.schema_id "
596 + "order by synonym_name,table_owner,table_name",
599 + " c.name as table_name, "
600 + " a.name as constraint_name, "
601 + " d.name as column_name, "
602 + " b.constraint_column_id as position, "
603 + " e.name as r_table_name, "
604 + " f.name as r_column_name ,"
605 + " f.column_id as r_position "
606 + "from sys.foreign_keys as a "
607 + " inner join sys.foreign_key_columns as b "
608 + " on a.object_id = b.constraint_object_id "
609 + " inner join sys.tables as c "
610 + " on b.parent_object_id = c.object_id "
611 + " inner join sys.columns as d "
612 + " on b.parent_object_id = d.object_id and "
613 + " b.parent_column_id = d.column_id "
614 + " inner join sys.tables as e "
615 + " on b.referenced_object_id = e.object_id "
616 + " inner join sys.columns as f "
617 + " on b.referenced_object_id = f.object_id and "
618 + " b.referenced_column_id = f.column_id "
619 + " inner join sys.key_constraints as g "
620 + " on a.referenced_object_id = g.parent_object_id "
621 + "order by table_name,constraint_name, position"
626 + " replace(replace(a.table_comment, char(13), ''), char(10), '') as table_comments, "
628 + " replace(replace(b.column_comment, char(13), ''), char(10), '') as column_comment, "
630 + " b.character_maximum_length as data_precision,"
631 + " b.numeric_precision as data_precision,"
632 + " b.numeric_scale as data_scale,"
633 + " case b.is_nullable"
634 + " when 'NO' then '
\81Z'"
636 + " end as nullable,"
637 + " column_default as data_default "
639 + " information_schema.tables a,"
640 + " information_schema.columns b "
642 + " a.table_schema = database()"
643 + " and a.table_type = 'BASE TABLE'"
644 + " and a.table_schema = b.table_schema "
645 + " and a.table_name = b.table_name "
646 + "order by a.table_name,b.ordinal_position",
649 + " b.constraint_name as index_name,"
650 + " '' as index_type, "
651 + " case b.constraint_type "
652 + " when 'PRIMARY KEY' then 'P' "
653 + " when 'UNIQUE' then 'U' "
654 + " end as constraint_type,"
656 + " c.ordinal_position as column_position"
658 + " information_schema.tables a,"
659 + " information_schema.table_constraints b,"
660 + " information_schema.key_column_usage c"
662 + " a.table_schema = database()"
663 + " and a.table_type = 'BASE TABLE'"
664 + " and a.table_schema = b.table_schema"
665 + " and a.table_name = b.table_name"
666 + " and b.table_schema = c.table_schema"
667 + " and b.table_name = c.table_name"
668 + " and b.constraint_name = c.constraint_name"
669 + " and b.constraint_type in('PRIMARY KEY','UNIQUE')"
673 + " b.index_type as index_type, "
674 + " '' as constraint_type,"
676 + " a.seq_in_index as column_position"
678 + " information_schema.statistics a,"
679 + " information_schema.statistics b"
681 + " a.table_schema = database()"
682 + " and a.table_schema = b.table_schema"
683 + " and a.table_name = b.table_name"
684 + " and a.index_name = b.index_name"
685 + " and a.non_unique = 1"
686 + " order by table_name,index_name,column_position",
688 + " a.table_name as view_name, "
691 + " information_schema.views a "
693 + " table_schema = database()"
697 + " routine_name as object_name, "
698 + " routine_type as object_type, "
699 + " '' as action_timing, "
700 + " '' as event_action, "
701 + " '' as event_object "
703 + " information_schema.routines "
705 + " routine_schema = database()"
706 + " and (routine_type = 'PROCEDURE' or routine_type = 'FUNCTION') "
708 + " trigger_name as object_name, "
709 + " 'TRIGGER' as object_type, "
710 + " action_timing as action_timing, "
711 + " event_manipulation as event_action, "
712 + " event_object_table as event_object "
714 + " information_schema.triggers "
716 + " trigger_schema = database()"
717 + " order by object_name,object_type ",
723 + " b.constraint_name, "
725 + " b.ordinal_position as position, "
726 + " b.referenced_table_name as r_table_name, "
727 + " b.referenced_column_name as r_column_name, "
728 + " c.ordinal_position as r_position "
730 + " information_schema.referential_constraints a, "
731 + " information_schema.key_column_usage b, "
732 + " information_schema.columns c "
734 + " a.constraint_schema = database() "
735 + " and a.constraint_schema = b.constraint_schema "
736 + " and a.constraint_name = b.constraint_name "
737 + " and b.referenced_table_name = c.table_name "
738 + " and b.referenced_column_name = c.column_name "
741 protected static String sql_view_text[] = {
742 "select text from user_views where view_name = ?",
743 "select c.definition "
744 + "from sys.views a "
745 + "inner join sys.objects b "
746 + "on b.object_id = a.object_id "
747 + "inner join sys.sql_modules c "
748 + "on c.object_id = b.object_id "
749 + "where a.name = ?",
750 "select view_definition from information_schema.views where table_name = ?"
752 protected static String sql_view_column_and_comment[] = {
755 + " replace(replace(d.comments, chr(13), ''), chr(10), '') as comments "
757 + " user_tab_columns b,"
758 + " user_col_comments d "
760 + " b.table_name = ? and"
761 + " b.table_name = d.table_name(+) and"
762 + " b.column_name = d.column_name(+) "
766 + " b.name as column_name, "
770 + " inner join sys.columns b on a.object_id = b.object_id and a.name = ? "
771 + " inner join sys.types c on b.system_type_id = c.system_type_id "
772 + " where a.type = 'V' "
773 + " and c.user_type_id <> 256 "
774 + " order by b.column_id",
777 + " replace(replace(column_comment, char(13), ''), char(10), '') as column_comment "
779 + " information_schema.columns "
782 + " order by ordinal_position"
784 protected static String sql_proc[] = {
785 "select text from user_source where type = ? and name = ? order by line",
786 "select d.definition "
788 + " (select a.name,'PROCEDURE' as type,c.definition "
789 + "from sys.procedures a "
790 + "inner join sys.objects b "
791 + "on b.object_id = a.object_id "
792 + "inner join sys.sql_modules c "
793 + "on c.object_id = b.object_id "
795 + " a.name,'FUNCTION' as type,c.definition "
796 + "from sys.objects a "
797 + "inner join sys.objects b "
798 + "on b.object_id = a.object_id "
799 + "inner join sys.sql_modules c "
800 + "on c.object_id = b.object_id and a.type in('FN', 'FS', 'FT', 'IF', 'TF') "
802 + "a.name,'TRIGGER' as type,c.definition "
803 + "from sys.triggers a "
804 + "inner join sys.objects b "
805 + "on b.object_id = a.object_id "
806 + "inner join sys.sql_modules c "
807 + "on c.object_id = b.object_id) d "
808 + "where d.type = ? and d.name = ?",
809 "select a.definition "
813 + " routine_name as object_name, "
814 + " routine_type as object_type, "
815 + " routine_definition as definition "
817 + " information_schema.routines "
819 + " routine_schema = database() "
821 + " trigger_name as object_name, "
822 + " 'TRIGGER' as object_type, "
823 + " action_statement as definition "
825 + " information_schema.triggers "
827 + " trigger_schema = database() "
830 + " a.object_type = ? "
831 + " and a.object_name = ? "
834 protected String user = null;
835 protected String pass = null;
836 protected String url = null;
837 protected String driver = null;
838 protected String outFolder = null;
839 protected String inFolder = null;
840 protected String lineSeparator = System.getProperty("line.separator");
841 protected String inColLineSeparator = System.getProperty("line.separator");
842 protected String fileEncoding = System.getProperty("file.encoding");
843 protected String nullMark = "";
844 protected String delimiter = "\t";
845 protected String fileExtension = "tsv";
846 protected boolean isSpcPadding = false;
847 protected String sqlQuotedS = null;
848 protected String sqlQuotedE = null;
849 protected String tSql = null;
850 protected String tkSql = null;
851 protected boolean isOrder = false;
852 protected boolean isQuotation = true;
853 protected boolean isPhysical = false;
854 protected boolean isDrop = false;
855 protected int batchCount = 1000;
856 protected String inclTables = null;
857 protected String exclTables = null;
858 protected String inclCols = null;
859 protected String exclCols = null;
860 protected String inclColsMask = null;
861 protected String exclColsMask = null;
862 protected char singleByteMaskChar = '*';
863 protected char doubleByteMaskChar = '\u25A0';
864 protected String maskPattern = "ALT";
865 protected String metaFolder = "DDL";
867 protected String [] inclTablesArray = null;
868 protected String [] exclTablesArray = null;
869 protected String [] inclColsArray = null;
870 protected String [] exclColsArray = null;
871 protected String [] inclColsMaskArray = null;
872 protected String [] exclColsMaskArray = null;
873 protected boolean isInclTables = false;
874 protected boolean isExclTables = false;
875 protected boolean isInclCols = false;
876 protected boolean isExclCols = false;
877 protected boolean isMask = false;
878 protected boolean isInclColsMask = false;
879 protected boolean isExclColsMask = false;
880 protected int dbType = DB_TYPE_UNKNOWN;
882 protected void getProperties(String _propFile) throws Exception{
883 BufferedReader br = null;
884 Properties prop = null;
886 prop = new Properties();
887 br = new BufferedReader(new InputStreamReader(CmnProps.class.getClassLoader().getResourceAsStream(_propFile), "UTF-8"));
889 for(int i=0;i<KEYS;i++){
890 prop_val[i] = prop.getProperty(database + "." +PROP_KEY[i]);
894 } catch (NullPointerException e) {
895 throw new Exception("
\83v
\83\8d\83p
\83e
\83B
\83t
\83@
\83C
\83\8b\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ
\81B[" + _propFile +"]");
896 } catch (IOException e) {
906 catch (IOException e) {
917 protected void setProperty(String _database) throws Exception{
918 database = _database;
919 if(database != null){
920 if(!CmnUtils.isEmpty(prop_val[D_PROPFILE])){
921 getProperties(System.getProperty(prop_val[D_PROPFILE]));
923 getProperties(DEFAULT_PROP_FILE);
927 for(int i=0;i<KEYS;i++){
928 if(System.getProperty(PROP_KEY[i])!=null)prop_val[i] = System.getProperty(PROP_KEY[i]);
929 CmnUtils.debugPrint(PROP_KEY[i] + "=" + prop_val[i]);
932 if(!CmnUtils.isEmpty(prop_val[D_USER]))user = prop_val[D_USER];
933 if(!CmnUtils.isEmpty(prop_val[D_PASS]))pass = prop_val[D_PASS];
934 if(!CmnUtils.isEmpty(prop_val[D_URL]))url = prop_val[D_URL];
935 if(!CmnUtils.isEmpty(prop_val[D_DRIVER]))driver = prop_val[D_DRIVER];
936 if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT];
937 if(!CmnUtils.isEmpty(prop_val[D_INPUT]))inFolder = prop_val[D_INPUT];
938 if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]);
939 if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))inColLineSeparator = CmnUtils.getLineSeparator(prop_val[D_INLINESEP]);
940 if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE];
941 if(!CmnUtils.isEmpty(prop_val[D_NULLMARK]))nullMark = prop_val[D_NULLMARK];
942 if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]);
943 if(!CmnUtils.isEmpty(prop_val[D_TBLSQL]))tSql = prop_val[D_TBLSQL];
944 if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL]))tkSql = prop_val[D_TBLKEYSQL];
945 if(!CmnUtils.isEmpty(prop_val[D_ORDER]) && prop_val[D_ORDER].toUpperCase().equals("Y"))isOrder = true;
946 if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]) && prop_val[D_QUOTATION].toUpperCase().equals("N"))isQuotation = false;
947 if(!CmnUtils.isEmpty(prop_val[D_PHYSICAL]) && prop_val[D_PHYSICAL].toUpperCase().equals("Y"))isPhysical = true;
948 if(!CmnUtils.isEmpty(prop_val[D_DROP]) && prop_val[D_DROP].toUpperCase().equals("Y"))isDrop = true;
949 if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]) && CmnUtils.isNumeric(prop_val[D_BATCOUNT]))batchCount = Integer.parseInt(prop_val[D_BATCOUNT]);
950 if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))isInclTables = true;
951 if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))isExclTables = true;
952 if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))isInclCols = true;
953 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))isExclCols = true;
954 if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))isInclColsMask = true;
955 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))isExclColsMask = true;
956 if(isInclColsMask || isExclColsMask)isMask = true;
957 if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTables = prop_val[D_INCLTAB].toUpperCase();
958 if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTables = prop_val[D_EXCLTAB].toUpperCase();
959 if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclCols = prop_val[D_INCLCOL].toUpperCase();
960 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclCols = prop_val[D_EXCLCOL].toUpperCase();
961 if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMask = prop_val[D_INCLCOLMASK].toUpperCase();
962 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMask = prop_val[D_EXCLCOLMASK].toUpperCase();
963 if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTablesArray = CmnUtils.splitCsv(prop_val[D_INCLTAB].toUpperCase());
964 if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTablesArray = CmnUtils.splitCsv(prop_val[D_EXCLTAB].toUpperCase());
965 if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclColsArray = CmnUtils.splitCsv(prop_val[D_INCLCOL].toUpperCase());
966 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclColsArray = CmnUtils.splitCsv(prop_val[D_EXCLCOL].toUpperCase());
967 if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMaskArray = CmnUtils.splitCsv(prop_val[D_INCLCOLMASK].toUpperCase());
968 if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMaskArray = CmnUtils.splitCsv(prop_val[D_EXCLCOLMASK].toUpperCase());
969 if(!CmnUtils.isEmpty(prop_val[D_SBYTEMASKCHR]))singleByteMaskChar = prop_val[D_SBYTEMASKCHR].charAt(0);
970 if(!CmnUtils.isEmpty(prop_val[D_DBYTEMASKCHR]))doubleByteMaskChar = prop_val[D_DBYTEMASKCHR].charAt(0);
971 if(!CmnUtils.isEmpty(prop_val[D_MASKPTN]))maskPattern = prop_val[D_MASKPTN];
972 if(!CmnUtils.isEmpty(prop_val[D_METAFOLDER]))metaFolder = prop_val[D_METAFOLDER];
973 if(!CmnUtils.isEmpty(prop_val[D_SPCPADDING]) && prop_val[D_SPCPADDING].toUpperCase().equals("Y"))isSpcPadding = true;
974 if(!CmnUtils.isEmpty(prop_val[D_FILEEXT]))fileExtension = prop_val[D_FILEEXT];
976 if(CmnUtils.isEmpty(user)){
977 throw new Exception("us(
\83\86\81[
\83UID)
\82ª
\96¢
\8ew
\92è
\82Å
\82·
\81B");
978 } else if (CmnUtils.isEmpty(pass)){
979 throw new Exception("pw(
\83p
\83X
\83\8f\81[
\83h)
\82ª
\96¢
\8ew
\92è
\82Å
\82·
\81B");
980 } else if (CmnUtils.isEmpty(url)){
981 throw new Exception("url(
\90Ú
\91±
\8fî
\95ñ)
\82ª
\96¢
\8ew
\92è
\82Å
\82·
\81B");
982 } else if (CmnUtils.isEmpty(driver)){
983 throw new Exception("dr(
\83h
\83\89\83C
\83o)
\82ª
\96¢
\8ew
\92è
\82Å
\82·
\81B");
986 for(int i = 0;i<DB_TYPE_NAME.length;i++){
987 if (url.toUpperCase().contains(DB_TYPE_NAME[i])){
993 if (dbType != DB_TYPE_UNKNOWN){
994 if(!CmnUtils.isEmpty(prop_val[D_TBLSQL])){
995 tSql = prop_val[D_TBLSQL];
997 tSql = T_SQL_ARRAY[dbType];
999 if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL])){
1000 tkSql = prop_val[D_TBLKEYSQL];
1002 tkSql = TK_SQL_ARRAY[dbType];
1004 if(!CmnUtils.isEmpty(prop_val[D_SQLQUOTEDS])){
1005 sqlQuotedS = prop_val[D_SQLQUOTEDS];
1007 sqlQuotedS = DB_SQL_QUOTEDS[dbType];
1009 if(!CmnUtils.isEmpty(prop_val[D_SQLQUOTEDE])){
1010 sqlQuotedE = prop_val[D_SQLQUOTEDE];
1012 sqlQuotedE = DB_SQL_QUOTEDE[dbType];
1015 throw new Exception("
\83f
\81[
\83^
\83x
\81[
\83X
\90»
\95i
\82ª
\8e¯
\95Ê
\82Å
\82«
\82Ü
\82¹
\82ñ
\81B[" + url + "]");
1018 if(database!=null)CmnUtils.infoPrint("-->
\91Î
\8fÛ
\83f
\81[
\83^
\83x
\81[
\83X='" + database.toUpperCase() + "'");
1019 if(!CmnUtils.isEmpty(prop_val[D_FILEEXT]))CmnUtils.infoPrint("-->
\83t
\83@
\83C
\83\8b\8ag
\92£
\8eq='" + prop_val[D_FILEEXT] + "'");
1020 if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))CmnUtils.infoPrint("-->
\8bæ
\90Ø
\82è
\95¶
\8e\9a='" + prop_val[D_DELIMITER] + "'");
1021 if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))CmnUtils.infoPrint("-->
\89ü
\8ds
\83R
\81[
\83h='" + prop_val[D_LINESEP] + "'");
1022 if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))CmnUtils.infoPrint("-->
\83J
\83\89\83\80\93à
\89ü
\8ds
\83R
\81[
\83h='" + prop_val[D_INLINESEP] + "'");
1023 if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))CmnUtils.infoPrint("-->
\95¶
\8e\9a\83R
\81[
\83h='" + prop_val[D_FILENCODE] + "'");
1024 if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]))CmnUtils.infoPrint("-->
\88ø
\97p
\8bå=" + CmnUtils.getYesNo(isQuotation));
1025 if(!CmnUtils.isEmpty(prop_val[D_SQLQUOTEDS]) && !CmnUtils.isEmpty(prop_val[D_SQLQUOTEDE]))CmnUtils.infoPrint("-->SQL
\88ø
\97p
\95\84=" + "'" + sqlQuotedS + "' '" + sqlQuotedE + "'");
1026 if(!CmnUtils.isEmpty(prop_val[D_ORDER]))CmnUtils.infoPrint("-->
\83\
\81[
\83g=" + CmnUtils.getYesNo(isOrder));
1027 if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))CmnUtils.infoPrint("-->
\83o
\83b
\83`
\8f\88\97\9d\90\94=" + batchCount);
1028 if(isSpcPadding)CmnUtils.infoPrint("-->
\8bó
\94\92\96\84\82ß=" + CmnUtils.getYesNo(isSpcPadding));
1029 if(isInclTables)CmnUtils.infoPrint("-->
\91Î
\8fÛ
\83e
\81[
\83u
\83\8b='" + inclTables.toUpperCase() + "'");
1030 if(isExclTables)CmnUtils.infoPrint("-->
\8f\9c\8aO
\83e
\81[
\83u
\83\8b='" + exclTables.toUpperCase() + "'");
1031 if(isInclCols)CmnUtils.infoPrint("-->
\91Î
\8fÛ
\83J
\83\89\83\80='" + inclCols.toUpperCase() + "'");
1032 if(isExclCols)CmnUtils.infoPrint("-->
\8f\9c\8aO
\83J
\83\89\83\80='" + exclCols.toUpperCase() + "'");
1034 CmnUtils.infoPrint("-->
\83}
\83X
\83L
\83\93\83O=" + CmnUtils.getYesNo(isMask));
1035 CmnUtils.infoPrint("-->
\83}
\83X
\83N
\83L
\83\93\83O
\83p
\83^
\81[
\83\93=" + maskPattern.toUpperCase());
1036 CmnUtils.infoPrint("-->
\94¼
\8ap
\83}
\83X
\83N
\95¶
\8e\9a='" + singleByteMaskChar + "'");
1037 CmnUtils.infoPrint("-->
\91S
\8ap
\83}
\83X
\83N
\95¶
\8e\9a='" + doubleByteMaskChar + "'");
1038 if(isInclColsMask)CmnUtils.infoPrint("-->
\83}
\83X
\83N
\91Î
\8fÛ
\83J
\83\89\83\80='" + inclColsMask.toUpperCase() + "'");
1039 if(isExclColsMask)CmnUtils.infoPrint("-->
\83}
\83X
\83N
\8f\9c\8aO
\83J
\83\89\83\80='" + exclColsMask.toUpperCase() + "'");