# Exception when executing JDBC query exception=\>Sequel::DatabaseError, :message=\>"Java::ComMicrosoftSqlserverJdbc::SQLServerException: Connection reset", :cause=\>"# \<Java::ComMicrosoftSqlserverJdbc::SQLServerException: Connection reset

**URL:** <https://discuss.elastic.co/t/exception-when-executing-jdbc-query-exception-sequel-databaseerror-message-java-connection-reset-cause-java-connection-reset/345562>\
**Category:** Logstash\
**Created:** [October 23, 2023, 11:58am UTC](https://discuss.elastic.co/t/exception-when-executing-jdbc-query-exception-sequel-databaseerror-message-java-connection-reset-cause-java-connection-reset/345562 "2023-10-23T11:58:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vishweshwar](https://avatars.discourse-cdn.com/v4/letter/v/b2d939/32.png) [@Vishweshwar](https://discuss.elastic.co/u/Vishweshwar)\
**Post date:** [October 23, 2023, 11:58am UTC](https://discuss.elastic.co/t/exception-when-executing-jdbc-query-exception-sequel-databaseerror-message-java-connection-reset-cause-java-connection-reset/345562/1 "2023-10-23T11:58:58Z")

</div>

For some time i am able to connect DB but after few seconds i get the error "Exception when executing JDBC query "

My logstash config format:  
input {  
jdbc {  
tags =\> "index.conf"  
jdbc\_connection\_string =\> "jdbc:sqlserver://XXXXXXX;databaseName=XXXX;Integrated Security=fale;TrustServerCertificate=true;Connect Timeout=600;Command Timeout=120"  
jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
jdbc\_driver\_library =\> "D:\XXXX\XXXX\lib/mssql-jdbc-12.4.1.jre11.jar"  
jdbc\_user =\> "XXXXX"  
jdbc\_password =\> "XXXXX"  
tracking\_column =\> "modifieddate"  
use\_column\_value =\> true  
jdbc\_pool\_timeout =\> 50  
jdbc\_validate\_connection =\> true  
jdbc\_validation\_timeout =\>3600  
connection\_retry\_attempts =\> 2  
tracking\_column\_type =\> "timestamp"  
schedule =\> "\*/2 \* \* \* \*"   
statement =\> "SELECT col1,col2,modifieddate AAA WHERE modifieddate \> DATEADD(HH,-1,:sql\_last\_value)"  
last\_run\_metadata\_path =\> "D:\XXXX\XXXX\configfiles\lastrun/.logstash-8.6.2\_jdbc\_last\_run\_index"  
}  
tcp {  
codec =\> fluent  
port =\> 7000  
tcp\_keep\_alive =\> true  
}  
}

filter {  
if "index.conf" in [tags]{  
mutate {  
copy =\> { "col1" =\> "[col1]"} }  
}  
}

output {  
if "index.conf" in [tags]{  
azuresearch {  
endpoint =\> "XXXcognitivesearchXXXX.XXXX.XXXX.Xet"  
api\_key =\> "XXXXXXX"  
search\_index =\> "admindata"  
column\_names =\> ['col1','col2','modifieddate']

}  
}  
}

Using below:

1. MS SQL to connect DB
2. Logstash 8.6.2
3. output- Azure cognitive search index.

Approaches Tried:

1. Increased connection timeout in connection string.
2. Added jdbc connection pool timeout
3. connection retry

There is no article for this issue to fix. Can anyone pls let me know hot to fix this issue?

---

<div class="post-metadata">

**Author:** ![Vishweshwar](https://avatars.discourse-cdn.com/v4/letter/v/b2d939/32.png) [@Vishweshwar](https://discuss.elastic.co/u/Vishweshwar)\
**Post date:** [October 24, 2023, 7:57am UTC](https://discuss.elastic.co/t/exception-when-executing-jdbc-query-exception-sequel-databaseerror-message-java-connection-reset-cause-java-connection-reset/345562/2 "2023-10-24T07:57:36Z")

</div>

Can anyone please share your inputs on this issue?

The sql query executes in max 4 seconds. Logstash scehduler is set for every 2 mins but still the connection reset issue exists.

---

<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:** [November 21, 2023, 7:58am UTC](https://discuss.elastic.co/t/exception-when-executing-jdbc-query-exception-sequel-databaseerror-message-java-connection-reset-cause-java-connection-reset/345562/3 "2023-11-21T07:58:09Z")

</div>

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