Error: com.mysql.cj.jdbc.Driver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?

Hi All,

I don't understand what's wrong in below conf file.

input {
jdbc {
jdbc_driver_library => "/usr/share/logstash/myjars/mysql-connector-java-8.0.11.jar"
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://10.0.1.133:5500/alumini_factor"
jdbc_user => "root"
jdbc_password => "********"
statement => "select * FROM profile"
use_column_value => true
tracking_column => id
}
}

output {
elasticsearch {
document_id => "%{id}"
hosts => ["http://localhost:9200"]
index => "profiles"
document_type => "data"
}
}

P.S:
Elasticsearch version 7.0.1
Logstash version 7.3
Mysql verion 5.7.26-0ubuntu0.16.04.1

Thanks,
Manideep

Are you using JDK 11?

hi @guyboertje

I think it is JDK 8.

image

Thanks,
Manideep

Did you try using the "old" driver class com.mysql.jdbc.Driver?

Hi @guyboertje

Thanks for the response.

I figured out the error.

As I am new to Linux, I did not understand the Logstash installation process.

i tried installing Logstash using APT given in the Logstash Docs.

Logstash was installed at /usr/share/logstash but the config folder was missing inside the Logstash.
So, I externally copied the config folder inside the Logstash and tried to run it. It did not work.

Sometime later, i realized that config folder from original installation was in /etc/config.

So, I have two config folders one inside the Logstash and another in /etc/. (I am really not sure if this is the issue.)

Then, I deleted everything and downloaded tat.gz file and extracted to the location /usr/share/.

It now has config folder. I ran the logstash with my conf file and it worked.

Thanks,
Manideep

In my local windows, I used new driver as the jar is 8.0.1.

Now, in the linux, I used old driver as the jar is 5.1.38.