embulk-input-mysql 0.8.4 → 0.8.5

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: e95b049dedfd17520d5aec37672353c4c79b1e0f
4
- data.tar.gz: cc6e270fae22085306a866f4fb614f77f7f30d88
3
+ metadata.gz: ba43696df83d63a83d601310565acb3ee822c46a
4
+ data.tar.gz: 73294973cfef407dd7fedbe748d662d911763933
5
5
  SHA512:
6
- metadata.gz: 97f583757f6ec44fba8f2eb4103bffdb09aef579e4745c1121c09a8194c98503a49d31d33e7e7fbe34af3629f8b2f427d09af020e5afcce98c060937c7ab7ba7
7
- data.tar.gz: 282b89a3573cc9145fddd2ff7bc181a212ed516c769a7df4d9f84a84349bd3eeddaa8275547b35dab47e4c607960ad8fce1f75c0525325e55342772bdac66254
6
+ metadata.gz: a0d7cec83ab2439308895c4803f0d92c0fea0cafff0376050f556dd7104804a20122d828033e12dd08a8da812badb683cd2ab3de033694154bfabac42e9bcc0d
7
+ data.tar.gz: 7880efc726e147fe90d3f5dba3d235d3c9a6312aa3984a4d54e3e28fb8d94b8ee4878488f5c2d69fdc7d0ca709e19a37d134ae66a5c7e468279e9bc5899eabd0
data/README.md CHANGED
@@ -9,6 +9,7 @@ MySQL input plugin for Embulk loads records from MySQL.
9
9
 
10
10
  ## Configuration
11
11
 
12
+ - **driver_path**: path to the jar file of the MySQL JDBC driver. If not set, the bundled JDBC driver (MySQL Connector/J 5.1.34) will be used. (string)
12
13
  - **host**: database host name (string, required)
13
14
  - **port**: database port number (integer, 3306)
14
15
  - **user**: database login user name (string, required)
data/build.gradle CHANGED
@@ -2,6 +2,7 @@ dependencies {
2
2
  compile project(':embulk-input-jdbc')
3
3
 
4
4
  compile 'mysql:mysql-connector-java:5.1.34'
5
+ defaultJdbcDriver 'mysql:mysql-connector-java:5.1.34'
5
6
 
6
7
  testCompile 'org.embulk:embulk-standards:0.8.15'
7
8
  }
@@ -4,11 +4,12 @@ import java.io.IOException;
4
4
  import java.lang.reflect.Field;
5
5
  import java.util.Properties;
6
6
  import java.sql.Connection;
7
- import java.sql.Driver;
7
+ import java.sql.DriverManager;
8
8
  import java.sql.SQLException;
9
9
 
10
+ import com.google.common.base.Optional;
10
11
  import com.google.common.base.Throwables;
11
- import com.mysql.jdbc.TimeUtil;
12
+
12
13
  import org.embulk.config.Config;
13
14
  import org.embulk.config.ConfigDefault;
14
15
  import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
@@ -27,6 +28,10 @@ public class MySQLInputPlugin
27
28
  public interface MySQLPluginTask
28
29
  extends PluginTask
29
30
  {
31
+ @Config("driver_path")
32
+ @ConfigDefault("null")
33
+ public Optional<String> getDriverPath();
34
+
30
35
  @Config("host")
31
36
  public String getHost();
32
37
 
@@ -60,6 +65,8 @@ public class MySQLInputPlugin
60
65
  {
61
66
  MySQLPluginTask t = (MySQLPluginTask) task;
62
67
 
68
+ loadDriver("com.mysql.jdbc.Driver", t.getDriverPath());
69
+
63
70
  String url = String.format("jdbc:mysql://%s:%d/%s",
64
71
  t.getHost(), t.getPort(), t.getDatabase());
65
72
 
@@ -67,7 +74,7 @@ public class MySQLInputPlugin
67
74
  props.setProperty("user", t.getUser());
68
75
  props.setProperty("password", t.getPassword());
69
76
 
70
- // convert 0000-00-00 to NULL to avoid this exceptoin:
77
+ // convert 0000-00-00 to NULL to avoid this exception:
71
78
  // java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
72
79
  props.setProperty("zeroDateTimeBehavior", "convertToNull");
73
80
 
@@ -110,14 +117,7 @@ public class MySQLInputPlugin
110
117
  // load timezone mappings
111
118
  loadTimeZoneMappings();
112
119
 
113
- Driver driver;
114
- try {
115
- driver = new com.mysql.jdbc.Driver(); // new com.mysql.jdbc.Driver throws SQLException
116
- } catch (SQLException ex) {
117
- throw new RuntimeException(ex);
118
- }
119
-
120
- Connection con = driver.connect(url, props);
120
+ Connection con = DriverManager.getConnection(url, props);
121
121
  try {
122
122
  MySQLInputConnection c = new MySQLInputConnection(con);
123
123
  con = null;
@@ -149,19 +149,20 @@ public class MySQLInputPlugin
149
149
  // Here implements a workaround as as workaround.
150
150
  Field f = null;
151
151
  try {
152
- f = TimeUtil.class.getDeclaredField("timeZoneMappings");
152
+ Class<?> timeUtilClass = Class.forName("com.mysql.jdbc.TimeUtil");
153
+ f = timeUtilClass.getDeclaredField("timeZoneMappings");
153
154
  f.setAccessible(true);
154
155
 
155
156
  Properties timeZoneMappings = (Properties) f.get(null);
156
157
  if (timeZoneMappings == null) {
157
158
  timeZoneMappings = new Properties();
158
- synchronized (TimeUtil.class) {
159
+ synchronized (timeUtilClass) {
159
160
  timeZoneMappings.load(this.getClass().getResourceAsStream("/com/mysql/jdbc/TimeZoneMapping.properties"));
160
161
  }
161
162
  f.set(null, timeZoneMappings);
162
163
  }
163
164
  }
164
- catch (IllegalAccessException | NoSuchFieldException | IOException e) {
165
+ catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException | IOException e) {
165
166
  throw Throwables.propagate(e);
166
167
  }
167
168
  finally {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Selects records from a table.
14
14
  email:
@@ -19,9 +19,9 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - README.md
21
21
  - build.gradle
22
- - classpath/embulk-input-jdbc-0.8.4.jar
23
- - classpath/embulk-input-mysql-0.8.4.jar
24
- - classpath/mysql-connector-java-5.1.34.jar
22
+ - classpath/embulk-input-jdbc-0.8.5.jar
23
+ - classpath/embulk-input-mysql-0.8.5.jar
24
+ - default_jdbc_driver/mysql-connector-java-5.1.34.jar
25
25
  - lib/embulk/input/mysql.rb
26
26
  - src/main/java/org/embulk/input/MySQLInputPlugin.java
27
27
  - src/main/java/org/embulk/input/MySQLTimeZoneComparison.java