# Error logstash.inputs.jdbc Unable to connect to database

**URL:** <https://discuss.elastic.co/t/error-logstash-inputs-jdbc-unable-to-connect-to-database/177091>\
**Category:** Logstash\
**Created:** [April 16, 2019, 12:45pm UTC](https://discuss.elastic.co/t/error-logstash-inputs-jdbc-unable-to-connect-to-database/177091 "2019-04-16T12:45:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![medaly\_ahmed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medaly_ahmed/32/44262_2.png) [@medaly\_ahmed](https://discuss.elastic.co/u/medaly_ahmed)\
**Post date:** [April 16, 2019, 12:45pm UTC](https://discuss.elastic.co/t/error-logstash-inputs-jdbc-unable-to-connect-to-database/177091/1 "2019-04-16T12:45:16Z")

</div>

I am a beginner in logstash.  
I want to load my database "mydb" in the inddex "test". but I find an error with logstash:  
"error logstash.inputs.jdbc Unable to connect to database"  
this is my config file:

```
    `input {
 jdbc {
    jdbc_driver_library => "C:\logstash-6.7.1\bin\mysql-connector-java-5.1.15-bin.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/mydb"
    jdbc_user => "medaly"
	jdbc_password => "123456"
	statement => "SELECT * from contacts"
  }
}

output {
  elasticsearch { hosts => ["localhost:9200"] index => "test" }
  stdout { codec => rubydebug }
}

```

if I execute the command, it displays:

```
C:\logstash-6.7.1\bin>logstash -f logstash-factures.conf
Sending Logstash logs to C:/logstash-6.7.1/logs which is now configured via log4j2.properties
[2019-04-16T12:03:48,623][WARN][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2019-04-16T12:03:48,654][INFO][logstash.runner] Starting Logstash {"logstash.version"=>"6.7.1"}
[2019-04-16T12:04:02,577][INFO][logstash.pipeline] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50}
[2019-04-16T12:04:03,436][INFO][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://localhost:9200/]}}
[2019-04-16T12:04:03,780][WARN][logstash.outputs.elasticsearch] Restored connection to ES instance {:url=>"http://localhost:9200/"}
[2019-04-16T12:04:03,858][INFO][logstash.outputs.elasticsearch] ES Output version determined {:es_version=>6}
[2019-04-16T12:04:03,858][WARN][logstash.outputs.elasticsearch] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>6}
[2019-04-16T12:04:03,905][INFO][logstash.outputs.elasticsearch] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["//localhost:9200"]}
[2019-04-16T12:04:03,920][INFO][logstash.outputs.elasticsearch] Using default mapping template
[2019-04-16T12:04:03,998][INFO][logstash.outputs.elasticsearch] Index Lifecycle Management is set to 'auto', but will be disabled - Your Elasticsearch cluster is before 7.0.0, which is the minimum version required to automatically run Index Lifecycle Management
[2019-04-16T12:04:03,998][INFO][logstash.outputs.elasticsearch] Attempting to install template {:manage_template=>{"template"=>"logstash-*", "version"=>60001, "settings"=>{"index.refresh_interval"=>"5s"}, "mappings"=>{"_default_"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}, "geoip"=>{"dynamic"=>true, "properties"=>{"ip"=>{"type"=>"ip"}, "location"=>{"type"=>"geo_point"}, "latitude"=>{"type"=>"half_float"}, "longitude"=>{"type"=>"half_float"}}}}}}}}
[2019-04-16T12:04:04,717][INFO][logstash.pipeline] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x409742fb run>"}
[2019-04-16T12:04:04,780][INFO][logstash.agent] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2019-04-16T12:04:05,436][INFO][logstash.agent] Successfully started Logstash API endpoint {:port=>9600}
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
[2019-04-16T12:04:07,155][ERROR][logstash.inputs.jdbc] Unable to connect to database. Tried 1 times {:error_message=>"Java::JavaSql::SQLException: The server time zone value 'Temps universel coordonn├®' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support."}
[2019-04-16T12:04:07,202][ERROR][logstash.pipeline] A plugin had an unrecoverable error. Will restart this plugin.
  Pipeline_id:main
  Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"medaly", jdbc_password=><password>, statement=>"SELECT * from contacts", jdbc_driver_library=>"C:\\logstash-6.7.1\\bin\\mysql-connector-java-5.1.15-bin.jar", jdbc_connection_string=>"jdbc:mysql://localhost:3306/mydb", id=>"16c5b88811c5bf3585ffe06fd0b66bf9d8247979d1cf1e74ff374b93c2dff4e7", jdbc_driver_class=>"com.mysql.jdbc.Driver", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_63cae9c8-53d2-41ca-a80f-2d2c386a04dc", 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 00:00:00 UTC}, last_run_metadata_path=>"C:\\Users\\medaly/.logstash_jdbc_last_run", use_column_value=>false, tracking_column_type=>"numeric", clean_run=>false, record_last_run=>true, lowercase_column_names=>true>
  Error: Java::JavaSql::SQLException: The server time zone value 'Temps universel coordonn├®' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
  Exception: Sequel::DatabaseConnectionError
  Stack: com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(com/mysql/cj/jdbc/exceptions/SQLError.java:129)
.......
```

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [April 16, 2019, 3:21pm UTC](https://discuss.elastic.co/t/error-logstash-inputs-jdbc-unable-to-connect-to-database/177091/2 "2019-04-16T15:21:43Z")

</div>

> [@medaly\_ahmed](#):
>
> Error: Java::JavaSql::SQLException: The server time zone value 'Temps universel coordonn├®' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

[Google search for serverTimezone + jdbc](https://www.google.com/search?ei=tfK1XO3KM5Oc1fAPhoas0AQ&q=serverTimezone+jdbc&oq=serverTimezone+jdbc&gs_l=psy-ab.3..0j0i22i30l5.4520.5541..6021...0.0..0.54.258.5......0....1..gws-wiz.......0i71j0i67j0i10.VT3MzRbE5wQ)

---

<div class="post-metadata">

**Author:** ![medaly\_ahmed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medaly_ahmed/32/44262_2.png) [@medaly\_ahmed](https://discuss.elastic.co/u/medaly_ahmed)\
**Post date:** [April 16, 2019, 3:41pm UTC](https://discuss.elastic.co/t/error-logstash-inputs-jdbc-unable-to-connect-to-database/177091/3 "2019-04-16T15:41:39Z")

</div>

Thanks sir @guyboertje  
how can i resolve this error of the server time zone ?

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [April 16, 2019, 4:06pm UTC](https://discuss.elastic.co/t/error-logstash-inputs-jdbc-unable-to-connect-to-database/177091/4 "2019-04-16T16:06:13Z")

</div>

What timezone are your timestamps recorded in in the MySQL DB?

If UTC then you can add some parameters to the jdbc connection string.

```auto
jdbc:mysql://localhost/mydb?useTimezone=true&useLegacyDatetimeCode=false&serverTimezone=UTC

```

---

<div class="post-metadata">

**Author:** ![medaly\_ahmed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medaly_ahmed/32/44262_2.png) [@medaly\_ahmed](https://discuss.elastic.co/u/medaly_ahmed)\
**Post date:** [April 17, 2019, 10:03am UTC](https://discuss.elastic.co/t/error-logstash-inputs-jdbc-unable-to-connect-to-database/177091/5 "2019-04-17T10:03:16Z")

</div>

thank you sir, it works

---

<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:** [May 15, 2019, 10:03am UTC](https://discuss.elastic.co/t/error-logstash-inputs-jdbc-unable-to-connect-to-database/177091/6 "2019-05-15T10:03:23Z")

</div>

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