embulk-output-jdbc 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2782cbd059a5832c46cebd5d78867f1a54791139
4
- data.tar.gz: f6e892f5a6a08fc517eca09b4bb5f5fc90a0086d
3
+ metadata.gz: 22641808f55bed4bec132e7cd317220a6cfc289a
4
+ data.tar.gz: f6ecc3e8d4fa66dd0f78b79e0c27d99535a11136
5
5
  SHA512:
6
- metadata.gz: e090013694785cd6867fb3665d009793f7bc3c8cb22002bcb51d4f232bb9ff1eedac9741d9ce66c2135c1ac245b46fe3e3aec702ff7f364a1ca5a185d61036b7
7
- data.tar.gz: 5a9b400fd9882c7930b2c7bf839a829eb98aa612d611f3e5c5120dd3692f81f4d1604dac4945c5df328dc3a2bdbb13501a1e4461174ff8abaa68dda5f1029997
6
+ metadata.gz: 94bc52aa3d7ced7da88fd92f990b8cec391b131f27b4158faeeec7b1c0aad41445fab52389f1c6d2ecaef8d36ff2baa35cf38cc13682cecf2a8e1640c3e46edb
7
+ data.tar.gz: 4fb618c9f6cb3d23cfccc2999468fb060aee2b811d16686bcd74af929a973acfa07d059c3c93e45d0ce330d21916716d0d07b06982f3035205b7bc1a9ff96497
@@ -1,13 +1,19 @@
1
1
  package org.embulk.output;
2
2
 
3
+ import java.nio.file.Paths;
4
+ import java.util.Set;
5
+ import java.util.HashSet;
3
6
  import java.util.Properties;
4
7
  import java.sql.Driver;
5
8
  import java.io.IOException;
6
9
  import java.sql.Connection;
7
10
  import java.sql.SQLException;
11
+ import com.google.common.base.Optional;
8
12
  import com.google.common.base.Throwables;
9
13
  import org.embulk.spi.Exec;
14
+ import org.embulk.spi.PluginClassLoader;
10
15
  import org.embulk.config.Config;
16
+ import org.embulk.config.ConfigDefault;
11
17
  import org.embulk.output.jdbc.AbstractJdbcOutputPlugin;
12
18
  import org.embulk.output.jdbc.BatchInsert;
13
19
  import org.embulk.output.jdbc.StandardBatchInsert;
@@ -17,6 +23,8 @@ import org.embulk.output.jdbc.JdbcOutputConnection;
17
23
  public class JdbcOutputPlugin
18
24
  extends AbstractJdbcOutputPlugin
19
25
  {
26
+ private final static Set<String> loadedJarGlobs = new HashSet<String>();
27
+
20
28
  public interface GenericPluginTask extends PluginTask
21
29
  {
22
30
  @Config("driver_name")
@@ -24,6 +32,10 @@ public class JdbcOutputPlugin
24
32
 
25
33
  @Config("driver_class")
26
34
  public String getDriverClass();
35
+
36
+ @Config("driver_path")
37
+ @ConfigDefault("null")
38
+ public Optional<String> getDriverPath();
27
39
  }
28
40
 
29
41
  @Override
@@ -37,12 +49,22 @@ public class JdbcOutputPlugin
37
49
  {
38
50
  GenericPluginTask g = (GenericPluginTask) task;
39
51
 
52
+ if (g.getDriverPath().isPresent()) {
53
+ synchronized (loadedJarGlobs) {
54
+ String glob = g.getDriverPath().get();
55
+ if (!loadedJarGlobs.contains(glob)) {
56
+ loadDriverJar(glob);
57
+ loadedJarGlobs.add(glob);
58
+ }
59
+ }
60
+ }
61
+
40
62
  String url;
41
63
  if (g.getPort().isPresent()) {
42
64
  url = String.format("jdbc:%s://%s:%d/%s",
43
65
  g.getDriverName(), g.getHost(), g.getPort().get(), g.getDatabase());
44
66
  } else {
45
- url = String.format("jdbc:%s://%s:%d/%s",
67
+ url = String.format("jdbc:%s://%s/%s",
46
68
  g.getDriverName(), g.getHost(), g.getDatabase());
47
69
  }
48
70
 
@@ -56,6 +78,13 @@ public class JdbcOutputPlugin
56
78
  g.getSchema().orNull());
57
79
  }
58
80
 
81
+ private void loadDriverJar(String glob)
82
+ {
83
+ // TODO match glob
84
+ PluginClassLoader loader = (PluginClassLoader) getClass().getClassLoader();
85
+ loader.addPath(Paths.get(glob));
86
+ }
87
+
59
88
  private static class GenericOutputConnector
60
89
  implements JdbcOutputConnector
61
90
  {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-jdbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
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-25 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Inserts or updates records to a table.
14
14
  email:
@@ -39,7 +39,7 @@ files:
39
39
  - src/main/java/org/embulk/output/jdbc/setter/SqlTimestampColumnSetter.java
40
40
  - src/main/java/org/embulk/output/jdbc/setter/StringColumnSetter.java
41
41
  - src/test/java/org/embulk/output/TestJdbcOutputPlugin.java
42
- - classpath/embulk-output-jdbc-0.1.2.jar
42
+ - classpath/embulk-output-jdbc-0.1.3.jar
43
43
  homepage: https://github.com/embulk/embulk-output-jdbc
44
44
  licenses:
45
45
  - Apache 2.0