embulk-input-jdbc 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f90e12c2fee1a30c130f033663488322ea010a9
|
4
|
+
data.tar.gz: 9dbae6a7d01b3bda36606b6f269f1f7d2fdcddc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dbed8686fd882876041fe10914297a63d7cce394ef3e686abc12bba4104f0ac88e3e59b8ce100da98fffa8bbf31bc2f4f040ad77b2c310312e7da441113958a
|
7
|
+
data.tar.gz: e53a6be622d0ec449c946990cdaedb8a21b3fa83d3a593894dee39675adc3e793bb5c5d1718ae5eda5da8c28895a494abe5ffa0bd5b0a96e82f1b0c1582b5f82
|
Binary file
|
@@ -20,17 +20,30 @@ public class JdbcInputPlugin
|
|
20
20
|
{
|
21
21
|
private final static Set<String> loadedJarGlobs = new HashSet<String>();
|
22
22
|
|
23
|
-
public interface GenericPluginTask
|
23
|
+
public interface GenericPluginTask
|
24
|
+
extends PluginTask
|
24
25
|
{
|
25
|
-
@Config("
|
26
|
-
|
26
|
+
@Config("driver_path")
|
27
|
+
@ConfigDefault("null")
|
28
|
+
public Optional<String> getDriverPath();
|
27
29
|
|
28
30
|
@Config("driver_class")
|
29
31
|
public String getDriverClass();
|
30
32
|
|
31
|
-
@Config("
|
33
|
+
@Config("url")
|
34
|
+
public String getUrl();
|
35
|
+
|
36
|
+
@Config("user")
|
32
37
|
@ConfigDefault("null")
|
33
|
-
public Optional<String>
|
38
|
+
public Optional<String> getUser();
|
39
|
+
|
40
|
+
@Config("password")
|
41
|
+
@ConfigDefault("null")
|
42
|
+
public Optional<String> getPassword();
|
43
|
+
|
44
|
+
@Config("schema")
|
45
|
+
@ConfigDefault("null")
|
46
|
+
public Optional<String> getSchema();
|
34
47
|
}
|
35
48
|
|
36
49
|
@Override
|
@@ -42,11 +55,11 @@ public class JdbcInputPlugin
|
|
42
55
|
@Override
|
43
56
|
protected JdbcInputConnection newConnection(PluginTask task) throws SQLException
|
44
57
|
{
|
45
|
-
GenericPluginTask
|
58
|
+
GenericPluginTask t = (GenericPluginTask) task;
|
46
59
|
|
47
|
-
if (
|
60
|
+
if (t.getDriverPath().isPresent()) {
|
48
61
|
synchronized (loadedJarGlobs) {
|
49
|
-
String glob =
|
62
|
+
String glob = t.getDriverPath().get();
|
50
63
|
if (!loadedJarGlobs.contains(glob)) {
|
51
64
|
loadDriverJar(glob);
|
52
65
|
loadedJarGlobs.add(glob);
|
@@ -54,33 +67,28 @@ public class JdbcInputPlugin
|
|
54
67
|
}
|
55
68
|
}
|
56
69
|
|
57
|
-
String url;
|
58
|
-
if (g.getPort().isPresent()) {
|
59
|
-
url = String.format("jdbc:%s://%s:%d/%s",
|
60
|
-
g.getDriverName(), g.getHost(), g.getPort().get(), g.getDatabase());
|
61
|
-
} else {
|
62
|
-
url = String.format("jdbc:%s://%s/%s",
|
63
|
-
g.getDriverName(), g.getHost(), g.getDatabase());
|
64
|
-
}
|
65
|
-
|
66
70
|
Properties props = new Properties();
|
67
|
-
|
68
|
-
|
71
|
+
if (t.getUser().isPresent()) {
|
72
|
+
props.setProperty("user", t.getUser().get());
|
73
|
+
}
|
74
|
+
if (t.getPassword().isPresent()) {
|
75
|
+
props.setProperty("password", t.getPassword().get());
|
76
|
+
}
|
69
77
|
|
70
|
-
props.putAll(
|
78
|
+
props.putAll(t.getOptions());
|
71
79
|
|
72
80
|
Driver driver;
|
73
81
|
try {
|
74
82
|
// TODO check Class.forName(driverClass) is a Driver before newInstance
|
75
83
|
// for security
|
76
|
-
driver = (Driver) Class.forName(
|
84
|
+
driver = (Driver) Class.forName(t.getDriverClass()).newInstance();
|
77
85
|
} catch (Exception ex) {
|
78
86
|
throw Throwables.propagate(ex);
|
79
87
|
}
|
80
88
|
|
81
|
-
Connection con = driver.connect(
|
89
|
+
Connection con = driver.connect(t.getUrl(), props);
|
82
90
|
try {
|
83
|
-
JdbcInputConnection c = new JdbcInputConnection(con,
|
91
|
+
JdbcInputConnection c = new JdbcInputConnection(con, t.getSchema().orNull());
|
84
92
|
con = null;
|
85
93
|
return c;
|
86
94
|
} finally {
|
@@ -34,31 +34,10 @@ public abstract class AbstractJdbcInputPlugin
|
|
34
34
|
|
35
35
|
public interface PluginTask extends Task
|
36
36
|
{
|
37
|
-
@Config("host")
|
38
|
-
public String getHost();
|
39
|
-
|
40
|
-
@Config("port")
|
41
|
-
@ConfigDefault("null")
|
42
|
-
public Optional<Integer> getPort();
|
43
|
-
|
44
|
-
@Config("user")
|
45
|
-
public String getUser();
|
46
|
-
|
47
|
-
@Config("password")
|
48
|
-
@ConfigDefault("\"\"")
|
49
|
-
public String getPassword();
|
50
|
-
|
51
37
|
@Config("options")
|
52
38
|
@ConfigDefault("{}")
|
53
39
|
public Properties getOptions();
|
54
40
|
|
55
|
-
@Config("database")
|
56
|
-
public String getDatabase();
|
57
|
-
|
58
|
-
@Config("schema")
|
59
|
-
@ConfigDefault("null")
|
60
|
-
public Optional<String> getSchema();
|
61
|
-
|
62
41
|
@Config("table")
|
63
42
|
public String getTable();
|
64
43
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-jdbc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Selects records from a table.
|
14
14
|
email:
|
@@ -27,7 +27,7 @@ files:
|
|
27
27
|
- src/main/java/org/embulk/input/jdbc/getter/ColumnGetter.java
|
28
28
|
- src/main/java/org/embulk/input/jdbc/getter/ColumnGetterFactory.java
|
29
29
|
- src/main/java/org/embulk/input/jdbc/getter/ColumnGetters.java
|
30
|
-
- classpath/embulk-input-jdbc-0.
|
30
|
+
- classpath/embulk-input-jdbc-0.3.0.jar
|
31
31
|
homepage: https://github.com/embulk/embulk-input-jdbc
|
32
32
|
licenses:
|
33
33
|
- Apache 2.0
|