# Error when port data from mySQL

**URL:** <https://discuss.elastic.co/t/error-when-port-data-from-mysql/167344>\
**Category:** Logstash\
**Created:** [February 6, 2019, 6:17pm UTC](https://discuss.elastic.co/t/error-when-port-data-from-mysql/167344 "2019-02-06T18:17:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vschaefer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vschaefer/32/40641_2.png) [@vschaefer](https://discuss.elastic.co/u/vschaefer)\
**Post date:** [February 6, 2019, 6:17pm UTC](https://discuss.elastic.co/t/error-when-port-data-from-mysql/167344/1 "2019-02-06T18:17:00Z")

</div>

I'm a little desperate. I'm trying to index data from a MySQL database.  
But it just won't work. Can you tell me what I'm doing wrong?  
Elasticsearch and Kibana is running and the MySQL database is available.

Here is my config file:

```
input {
  jdbc { 
    jdbc_connection_string => "jdbc:mysql://localhost:3306/data_2019"
    # The user we wish to execute our statement as
    jdbc_user => "root"
    jdbc_password => ""
    # The path to our downloaded jdbc driver
    jdbc_driver_library => "/Users/volker/elastic/logstash-6.6.0/mysql-connector-java-8.0.15/mysql-connector-java-8.0.15.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    # our query
    statement => "SELECT * FROM dbo_daten_2019"
    }
  }
output {
  stdout { codec => json_lines }
  elasticsearch {
  "hosts" => "localhost:9200"
  "index" => "test-migrate"
  "document_type" => "data"
  }
}

```

And here's the error output on the terminal:

```
Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"root", jdbc_password=><password>, statement=>"SELECT * FROM dbo_artikeldaten_2019_01_de", jdbc_driver_library=>"/Users/volker/elastic/logstash-6.6.0/mysql-connector-java-8.0.15/mysql-connector-java-8.0.15.jar", jdbc_connection_string=>"jdbc:mysql://127.0.0.1/lightscout_data_2019", id=>"7f33589f3939a34064542ea6f3d0504ef0c23945020652a0b5156c8d319c9b17", jdbc_driver_class=>"com.mysql.jdbc.Driver", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_9f726a29-6efb-47df-9ed6-09107c732ed0", 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, parameters=>{"sql_last_value"=>1970-01-01 01:00:00 +0100}, last_run_metadata_path=>"/Users/volker/.logstash_jdbc_last_run", use_column_value=>false, tracking_column_type=>"numeric", clean_run=>false, record_last_run=>true, lowercase_column_names=>true>
Error: com.mysql.jdbc.Driver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?
Exception: LogStash::ConfigurationError
Stack: /Users/volker/elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:163:in `open_jdbc_connection'
/Users/volker/elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:221:in `execute_statement'
/Users/volker/elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:277:in `execute_query'
/Users/volker/elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:263:in `run'
/Users/volker/elastic/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:409:in `inputworker'
/Users/volker/elastic/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:403:in `block in start_input'
[2019-02-06T19:00:18,140][ERROR][logstash.inputs.jdbc] Failed to load /Users/volker/elastic/logstash-6.6.0/mysql-connector-java-8.0.15/mysql-connector-java-8.0.15.jar {:exception=>#<TypeError: failed to coerce jdk.internal.loader.ClassLoaders$AppClassLoader to java.net.URLClassLoader>}
[2019-02-06T19:00:18,145][ERROR][logstash.pipeline] A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main
```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 6, 2019, 7:40pm UTC](https://discuss.elastic.co/t/error-when-port-data-from-mysql/167344/2 "2019-02-06T19:40:26Z")

</div>

> [@vschaefer](#):
>
> failed to coerce jdk.internal.loader.ClassLoaders$AppClassLoader to java.net.URLClassLoader

Are you using Java 9? If so, can you test whether it works with Java 8?

---

<div class="post-metadata">

**Author:** ![vschaefer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vschaefer/32/40641_2.png) [@vschaefer](https://discuss.elastic.co/u/vschaefer)\
**Post date:** [February 6, 2019, 8:04pm UTC](https://discuss.elastic.co/t/error-when-port-data-from-mysql/167344/3 "2019-02-06T20:04:21Z")

</div>

Thanks for your reply. I'm using Java 8. Does it make sense to test it with Java 9?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 6, 2019, 8:28pm UTC](https://discuss.elastic.co/t/error-when-port-data-from-mysql/167344/4 "2019-02-06T20:28:06Z")

</div>

> [@vschaefer](#):
>
> Does it make sense to test it with Java 9?

No, I don't think so, it is just that the only hit I got for the error message "failed to coerce jdk.internal.loader.ClassLoaders$AppClassLoader to java.net.URLClassLoader" was due to a change made in Java 9.

I do not know what is causing this.

---

<div class="post-metadata">

**Author:** ![vschaefer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vschaefer/32/40641_2.png) [@vschaefer](https://discuss.elastic.co/u/vschaefer)\
**Post date:** [February 7, 2019, 2:31pm UTC](https://discuss.elastic.co/t/error-when-port-data-from-mysql/167344/5 "2019-02-07T14:31:06Z")

</div>

Hmm okay.  
I have changed the line

```
jdbc_driver_class => "com.mysql.jdbc.Driver"

```

to

```
jdbc_driver_class => "Java::com.mysql.jdbc.Driver"

```

But that didn't help either. The error message remains the same.  
Does anyone have an idea where the mistake might be?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 7, 2019, 2:31pm UTC](https://discuss.elastic.co/t/error-when-port-data-from-mysql/167344/6 "2019-03-07T14:31:07Z")

</div>

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