Skip to content

Commit e94cf65

Browse files
committed
Merge pull request #7 from DennisPallett/master
Several new features + improved speed and stability
2 parents d8d5eba + 3e61767 commit e94cf65

15 files changed

+1657
-607
lines changed

config.properties.example

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,26 @@
1-
# indicates how many records should be insert at a time into MonetDB
2-
batch.size = 10000
3-
4-
# Scheduling options
5-
# With this the tool will check this table/column in SQL server and determine
6-
# if there have been any changes since the last run
7-
#
8-
# scheduler.table = updated
9-
# scheduler.column = last_updatetime
10-
11-
mssql.user = dbuser
12-
mssql.password = dbpassword
13-
mssql.server = localhost
14-
mssql.database = my_db
15-
# optional instance name
16-
# mssql.instance = instance_name
17-
1+
# target MonetDB Database:
182
monetdb.user = monetdb
19-
monetdb.password = monetdb
3+
monetdb.password = ENV:MONETDB_PASSWORD:monetdb
204
monetdb.server = localhost
215
monetdb.database = my_monetdb
226

7+
# source MS SQL Server database(s):
8+
# multiple databases can be specified, each under their own sub-key
9+
mssql.db1.user = dbuser
10+
mssql.db1.password = dbpassword
11+
mssql.db1.server = localhost
12+
mssql.db1.database = my_db
13+
# optional instance name
14+
# mssql.db1.instance = instance_name
15+
2316
# copy a table
17+
table.example.source = db1
2418
table.example.from = example_table
2519
table.example.to = example_table_new
2620
table.example.schema = sys
2721
table.example.create = true
2822
table.example.truncate = true
2923

30-
# Mail settings
31-
monetdb.mail.sendmail=true
32-
monetdb.mail.to=my.name@something.com
33-
monetdb.mail.from=from@someone.com
34-
monetdb.mail.server=1.1.1.1
35-
monetdb.mail.port=8888
36-
monetdb.mail.username=
37-
monetdb.mail.password=
38-
3924
# use tmp_tables to copy the data to so we can recreate the
4025
# to-table for faster data transfer to the end table which
4126
# reduces down-time
@@ -49,5 +34,36 @@ table.example.tempTablePrefix = tmp_
4934
# resulting in almost no down-time of your database table
5035
# prefixes can be defined if you want custom naming
5136
table.example.useFastViewSwitching = false
52-
table.example.currentTablePrefix = current_
53-
table.example.backupTablePrefix = backup_
37+
38+
# Mail settings
39+
monetdb.mail.sendmail=true
40+
monetdb.mail.to=my.name@something.com
41+
monetdb.mail.from=from@someone.com
42+
monetdb.mail.server=1.1.1.1
43+
monetdb.mail.port=8888
44+
monetdb.mail.username=
45+
monetdb.mail.password=
46+
47+
# specifies a custom temp directory instead of the default system temp directory
48+
# temp.directory = /home/me/temp
49+
50+
# indicates how many records should be insert at a time into MonetDB
51+
# only used when using INSERT method to insert new data.
52+
batch.size = 10000
53+
54+
# Scheduling options
55+
# Enabling the scheduler will run the tool indefinitely and run the copy job
56+
# every X minutes/hours/days. Very useful in combination with the trigger options
57+
#
58+
# scheduler.enabled = true
59+
# scheduler.interval = every 5 minutes
60+
61+
# Trigger options
62+
# With this the tool will check this table/column in SQL server and determine
63+
# if there have been any changes since the last run. The copy job will only be executed
64+
# if there is new data in the trigger column.
65+
#
66+
# trigger.enabled = true
67+
# trigger.source = db1
68+
# trigger.table = updated
69+
# trigger.column = last_updatetime

pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>nl.topicus.mssql2monetdb</groupId>
55
<artifactId>mssql2monetdb</artifactId>
66
<packaging>jar</packaging>
7-
<version>0.4-SNAPSHOT</version>
7+
<version>0.5</version>
88
<name>mssql2monetdb</name>
99
<url>http://maven.apache.org</url>
1010

@@ -43,7 +43,13 @@
4343
<groupId>commons-lang</groupId>
4444
<artifactId>commons-lang</artifactId>
4545
<version>2.6</version>
46-
</dependency>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>net.sf.opencsv</groupId>
50+
<artifactId>opencsv</artifactId>
51+
<version>2.0</version>
52+
</dependency>
4753

4854
<!-- MonetDB JDBC driver -->
4955
<dependency>

src/main/java/nl/topicus/mssql2monetdb/CONFIG_KEYS.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
public enum CONFIG_KEYS
44
{
55
JOB_ID("job.id"),
6-
MSSQL_USER("mssql.user"),
7-
MSSQL_PASSWORD("mssql.password"),
8-
MSSQL_SERVER("mssql.server"),
9-
MSSQL_DATABASE("mssql.database"),
10-
MSSQL_INSTANCE("mssql.instance"),
116
MONETDB_USER("monetdb.user"),
127
MONETDB_PASSWORD("monetdb.password"),
138
MONETDB_SERVER("monetdb.server"),
@@ -19,10 +14,14 @@ public enum CONFIG_KEYS
1914
MONETDB_MAIL_PORT("monetdb.mail.port"),
2015
MONETDB_MAIL_USERNAME("monetdb.mail.username"),
2116
MONETDB_MAIL_PASSWORD("monetdb.mail.password"),
22-
ALLOW_MULTIPLE_INSTANCES("allow.multiple.instances", false),
23-
SCHEDULER_TABLE("scheduler.table", false),
24-
SCHEDULER_COLUMN("scheduler.column", false),
25-
BATCH_SIZE("batch.size", false);
17+
SCHEDULER_ENABLED("scheduler.enabled", false),
18+
SCHEDULER_INTERVAL("scheduler.interval", false),
19+
TRIGGER_ENABLED("trigger.enabled", false),
20+
TRIGGER_SOURCE("trigger.source", false),
21+
TRIGGER_TABLE("trigger.table", false),
22+
TRIGGER_COLUMN("trigger.column", false),
23+
BATCH_SIZE("batch.size", false),
24+
TEMP_DIR("temp.directory", false);
2625

2726
private final String key;
2827

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package nl.topicus.mssql2monetdb;
2+
3+
public class ConfigException extends Exception {
4+
5+
public ConfigException (String msg)
6+
{
7+
super(msg);
8+
}
9+
10+
}

src/main/java/nl/topicus/mssql2monetdb/CopyTable.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class CopyTable
2222
public static final int COPY_METHOD_INSERT = 0;
2323

2424
public static final int COPY_METHOD_COPYINTO = 1;
25-
26-
public static final int COPY_METHOD_COPYINTO_VIA_TEMP_FILE = 2;
2725

2826
// contains the actual result table and possible a temp table
2927
private List<MonetDBTable> monetDBTables = new ArrayList<MonetDBTable>();
@@ -33,13 +31,15 @@ public class CopyTable
3331
private boolean create = true;
3432

3533
private boolean drop = false;
34+
35+
private String source;
3636

3737
// secret view name
3838
private String toName;
3939

4040
private String fromName;
4141

42-
private String schema;
42+
private String schema = "sys";
4343

4444
private int copyMethod = COPY_METHOD_NOTSET;
4545

@@ -62,6 +62,18 @@ public class CopyTable
6262

6363
// this will do COPY INTO with LOCKED MODE
6464
private boolean useLockedMode = false;
65+
66+
private String loadDate;
67+
68+
public void setLoadDate(String loadDateStr)
69+
{
70+
this.loadDate = loadDateStr;
71+
}
72+
73+
public String getLoadDate()
74+
{
75+
return this.loadDate;
76+
}
6577

6678
public void setCopyMethod(int copyMethod)
6779
{
@@ -102,6 +114,16 @@ public boolean create()
102114
{
103115
return this.create;
104116
}
117+
118+
public String getSource ()
119+
{
120+
return source;
121+
}
122+
123+
public void setSource(String source)
124+
{
125+
this.source = source;
126+
}
105127

106128
public String getFromName()
107129
{
@@ -132,6 +154,11 @@ public void setSchema(String schema)
132154
{
133155
this.schema = schema;
134156
}
157+
158+
public String getTempFilePrefix ()
159+
{
160+
return "table_" + this.source + "_" + this.fromName;
161+
}
135162

136163
public List<MonetDBTable> getMonetDBTables()
137164
{

0 commit comments

Comments
 (0)