# URGENT! Elastic search: Unable to perform jdbc query because of Exception when executing JDBC query

**URL:** <https://discuss.elastic.co/t/urgent-elastic-search-unable-to-perform-jdbc-query-because-of-exception-when-executing-jdbc-query/291181>\
**Category:** Logstash\
**Tags:** jdbc\
**Created:** [December 8, 2021, 5:41am UTC](https://discuss.elastic.co/t/urgent-elastic-search-unable-to-perform-jdbc-query-because-of-exception-when-executing-jdbc-query/291181 "2021-12-08T05:41:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leo\_Baby\_Jacob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leo_baby_jacob/32/87425_2.png) [@Leo\_Baby\_Jacob](https://discuss.elastic.co/u/Leo_Baby_Jacob)\
**Post date:** [December 8, 2021, 5:41am UTC](https://discuss.elastic.co/t/urgent-elastic-search-unable-to-perform-jdbc-query-because-of-exception-when-executing-jdbc-query/291181/1 "2021-12-08T05:41:06Z")

</div>

I have a sample logstash conf file, However when I. run it I can see a logstash error caused  
Error is

```auto
    [371de1f7cad8c35c02e4a3047ec831da42b9b5048183b45a3916162ab248f3f7] Exception when executing JDBC query {:exception=>"Java::ComMysqlCjJdbcExceptions::CommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."}
Below is the logstash config file:

```

```auto
    input {
      jdbc {
        jdbc_driver_library => "/usr/share/logstash/mysql-connector-java-8.0.22.jar"
        jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
        jdbc_connection_string => "jdbc:mysql://xxx-1.x-xxxefxxxdxxxo3.us-east-2.rds.amazonaws.com:3306/sercdb_dev"
        jdbc_user => "user"
        jdbc_password => "pass"
        sql_log_level => "debug" # Set Logstash logging level as this
        clean_run => true # Set to true for indexing from scratch
        record_last_run => false
    	tracking_column => "id"
        statement => "SELECT * FROM people"
      }
    }
    
    ## Add your filters / logstash plugins configuration here
    
    output {
    	elasticsearch {
    		hosts => "elasticsearch:9200"
    		user => "elastic"
    		password => "elastic"
    		ecs_compatibility => disabled
    		index => "users"
        	action => "index"
        	document_id => "%{id}"
    	}
    }

```

---

<div class="post-metadata">

**Author:** ![AquaX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquax/32/92006_2.png) [@AquaX](https://discuss.elastic.co/u/AquaX)\
**Post date:** [December 8, 2021, 2:27pm UTC](https://discuss.elastic.co/t/urgent-elastic-search-unable-to-perform-jdbc-query-because-of-exception-when-executing-jdbc-query/291181/2 "2021-12-08T14:27:24Z")

</div>

Are you sure that the `jdbc_connection_string is correct`? A communication link failure exception usually happens when jdbc is not able to connect at all.  
This could be because of a TLS error, or your bind-address for your mysql server is not 0.0.0.0, your port is incorrect or not listening, your sql server is not running, a firewall is preventing external connections, and much more. You need to check all the basics first.

---

<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:** [January 5, 2022, 2:27pm UTC](https://discuss.elastic.co/t/urgent-elastic-search-unable-to-perform-jdbc-query-because-of-exception-when-executing-jdbc-query/291181/3 "2022-01-05T14:27:56Z")

</div>

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