macoselasticsearchmysql-connectorelasticsearch-jdbc-river

Elasticsearch JDBC-River Mysql - No suitable driver found for jdbc


I am trying to import a mysql table from mysql server to elasticsearch on my MAC OSX Mavericks.

  1. I have installed elasticsearch 1.3.1 with homebrew
  2. Installed jdbc-river 1.3.0.4 with elasticsearch plugin --install
  3. Installed jdk 1.7.0_67
  4. Downloaded mysql-connector-java-5.1.28-bin.jar into $ES_HOME/plugins/jdbc (I had to create the folders 'plugins' and 'jdbc' myself) and gave chmod 777 permission for the .jar file.
  5. Then I ran ./bin/elasticsearch and called this command in postman in order to create a river:

PUT request.

URL: localhost:9200/_river/my_jdbc_river/_meta

Raw data:

{
    "type" : "jdbc",
    "jdbc" : {
        "url" : "jdbc:mysql://localhost:3306/<databaseName>",
        "user" : "<MysqlUserName>",
        "password" : "<MysqlUserPass",
        "sql" : "select * from <TableName>"
    } 
}

And I received the following error in the elasticsearch log in the terminal:

    [2014-08-26 15:38:39,300][ERROR][org.xbib.elasticsearch.river.jdbc.strategy.simple.SimpleRiverSource] while opening read connection: jdbc:mysql://localhost:3306/xcollector No suitable driver found for jdbc:mysql://localhost:3306/xcollector
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/xcollector
    at java.sql.DriverManager.getConnection(DriverManager.java:596)
    at java.sql.DriverManager.getConnection(DriverManager.java:215)
    at org.xbib.elasticsearch.river.jdbc.strategy.simple.SimpleRiverSource.getConnectionForReading(SimpleRiverSource.java:196)
    at org.xbib.elasticsearch.river.jdbc.strategy.simple.SimpleRiverSource.execute(SimpleRiverSource.java:315)
    at org.xbib.elasticsearch.river.jdbc.strategy.simple.SimpleRiverSource.fetch(SimpleRiverSource.java:287)
    at org.xbib.elasticsearch.plugin.feeder.jdbc.JDBCFeeder.fetch(JDBCFeeder.java:335)
    at org.xbib.elasticsearch.plugin.feeder.jdbc.JDBCFeeder.executeTask(JDBCFeeder.java:179)
    at org.xbib.elasticsearch.plugin.feeder.AbstractFeeder.newRequest(AbstractFeeder.java:362)
    at org.xbib.elasticsearch.plugin.feeder.AbstractFeeder.newRequest(AbstractFeeder.java:53)
    at org.xbib.pipeline.AbstractPipeline.call(AbstractPipeline.java:87)
    at org.xbib.pipeline.AbstractPipeline.call(AbstractPipeline.java:14)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

I have followed many posts in google to try and find the cause of the problem, does anyone have any idea what I am missing?

And if anyone knows if this procedure can be more automatic to deploy like having some kind of package manager (like npm for node.js).

Thanks in advance,


Solution

  • So the clue to your problem is that you had to create the folders "plugins" and "jdbc" in step 4. Both of those folders are created when you install the mysql river plugin. I can see that the mysql river plugin installed correctly in your error message - it's running but it is unable to find the jdbc driver.

    Look on your drive for the correct folder - $ES_HOME should have the following folders in it:

    bin
    config
    data
    lib
    logs
    plugins
    

    If it does not then $ES_HOME is set incorrectly. Copy your jdbc driver as directed into the correct folder and you should be able to resolve this problem.