embulk/embulk-input-jdbc

Enabled to change MySQL JDBC driver

Closed this issue · 6 comments

embulk-input-mysql contains JDBC Driver, but it will be useful if users can use another JDBC driver in yml.
(Users must specify JDBC driver path for some of embulk-input-jdbc plugins (ex. embulk-input-oracle) because they cannot contain JDBC drivers for reasons of license.)

But AbstractJdbcInputPlugin#addDriverJarToClasspath doesn't work.
Because JDBC Driver contained in embulk-input-mysql will be loaded preferentially.

Two ideas:

  • Modify PluginClassLoader (in embulk) to enable to load preferentially jars added later.
  • Move JDBC Driver from the "classpath" directory. The driver won't be added to classpath automatically and embulk-input-mysql should find it and add to classpath if another driver is not specified in yml.
muga commented

@hito4t Agree with your thoughts 👍 I'm still not sure but, why we cannot take similar way with embulk-input-sqlserver's driver_path option?

@hito4t Interesting extension. Some questions:

  • From the version which starts this feature, MUST users specify the path to a JDBC driver, or do you want it to be optional? (In other words, does the plugin have a kind of "default" JDBC driver?)
  • Do you think the JDBC driver should be loaded before the plugin itself is loaded, or is it okay to load the JDBC driver by the plugin itself (maybe by implementing the plugin's own ClassLoader)?

Thought that MavenPluginSource (which is ongoing to implement) may help in some way. But, it is now restricted to load only one JAR (a kind of fat JAR) as a plugin. It is not to confuse users due to no version locks there like Bundler... I'm not very positive to do that in MavenPluginSource very soon casually, to be honest.

@muga
jtds SQL Server JDBC Driver, which is contained in embulk-input-sqlserver, and Microsoft SQL Server JDBC Driver have different class name.
So Microsoft Driver will be loaded even if jtds Driver is already added to classpath.
Users cannot use another jtds Driver.

@dmikurube

  • I think the driver path should be optional and the plugin should have a default driver because

    • it is easy for users to use the plugin
    • yml for the current version should work for future versions
  • Is is not necessary to load JDBC drivers with plugins. Plugins should load JDBC drivers in some initializing method.

For future reference
Discussed in twitter written in Japanese.

I've implemented!
#116

Would you review the PR?