Jdbc mariadb works in logstash 6.8, but not in logstash 7.5

We have updated our ES to 7.5 and therefore I am also updating our logstash'es. I know that Logstash 6.8 works with ES 7.5, so this is not a crisis.

BUT...

When I run these two config files, 6.8 works, but 7.5 don't. The mariadb drivers have been copied from the 6.8 folder to 7.5 folder. I have updated logstash-input-jdbc to 4.3.19 and I am out of ideas.

Logstash config 7.5

input {
   jdbc {
    jdbc_driver_library => "C:/Logstash/logstash-7.5.0/plugin/mariadb-java-client-2.4.2.jar"
    jdbc_driver_class => "Java::org.mariadb.jdbc.Driver"
    jdbc_connection_string => "jdbc:mariadb://XX.XX.XXX.X:XXXX/dbname"
    jdbc_user => "MYUSER"
    jdbc_password => "MYPASSWORD"
    statement => "select * from OrganizationFhir limit 10" 
  } 
}

filter {
}

output {
    stdout { codec => rubydebug } 

Logstash 6.8

input {
   jdbc {
    jdbc_driver_library => "C:/Logstash/logstash-6.8.0/plugin/mariadb-java-client-2.4.2.jar"
    jdbc_driver_class => "Java::org.mariadb.jdbc.Driver"
    jdbc_connection_string => "jdbc:mariadb://XX.XX.XXX.X:XXXX/dbname"
    jdbc_user => "MYUSER"
    jdbc_password => "MYPASSWORD"
    statement => "select * from OrganizationFhir limit 10" 
  } 
}

filter {
}

output {
    stdout { codec => rubydebug } 

I'm getting the following error message

[2019-12-10T10:20:55,437][ERROR][logstash.inputs.jdbc ][main] Unable to connect to database. Tried 1 times {:error_message=>"Java::JavaSql::SQLException: No suitable driver found for jdbc:mariadb://XX.XX.XXX.X:XXXX/dbname"}
[2019-12-10T10:20:55,437][ERROR][logstash.javapipeline ][main] A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"MYUSER", jdbc_password=>, statement=>"select * from OrganizationFhir limit 10", jdbc_driver_library=>"C:/Logstash/logstash-7.5.0/plugin/mariadb-java-client-2.4.2.jar", jdbc_connection_string=>"jdbc:mariadb://XX.XX.XXX.X:XXXX/dbname", id=>"a525f87a88a4afef35b7feb49deed1486f860dbc6b74947fca66a8c4673ca293", jdbc_driver_class=>"Java::org.mariadb.jdbc.Driver", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_e68fd36c-b0fd-4cfa-aa8e-35d8cc723ee7", enable_metric=>true, charset=>"UTF-8">, jdbc_paging_enabled=>false, jdbc_page_size=>100000, jdbc_validate_connection=>false, jdbc_validation_timeout=>3600, jdbc_pool_timeout=>5, sql_log_level=>"info", connection_retry_attempts=>1, connection_retry_attempts_wait_time=>0.5, plugin_timezone=>"utc", last_run_metadata_path=>"C:\Users\N1XERW/.logstash_jdbc_last_run", use_column_value=>false, tracking_column_type=>"numeric", clean_run=>false, record_last_run=>true, lowercase_column_names=>true, use_prepared_statements=>false>
Error: Java::JavaSql::SQLException: No suitable driver found for jdbc:mariadb://XX.XX.XXX.X:XXXX/dbname
Exception: Sequel::DatabaseConnectionError
Stack: java.sql.DriverManager.getConnection(java/sql/DriverManager.java:689)
java.sql.DriverManager.getConnection(java/sql/DriverManager.java:247)
java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)

As suggested in https://discuss.elastic.co/t/logstash-jdbc-class-cannot-found/209807 I changed the driver library to

jdbc_driver_library => "c:/logstash/logstash-7.5.0/lib/jars/mariadb-java-client-2.4.2.jar"

but my jdbc connection via logstash 7.5 still don't work. Are we looking at a undokumented breaking feature?

1 Like

The correct path is jdbc_driver_library =>{logstash_install_dir}/logstash-core/lib/jars/ and now it works

4 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.