# Logstash - After a certain amount of time, can not connect to the database

**URL:** <https://discuss.elastic.co/t/logstash-after-a-certain-amount-of-time-can-not-connect-to-the-database/145314>\
**Category:** Logstash\
**Created:** [August 21, 2018, 7:26am UTC](https://discuss.elastic.co/t/logstash-after-a-certain-amount-of-time-can-not-connect-to-the-database/145314 "2018-08-21T07:26:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyukjun\_choi](https://avatars.discourse-cdn.com/v4/letter/h/c68b51/32.png) [@hyukjun\_choi](https://discuss.elastic.co/u/hyukjun_choi)\
**Post date:** [August 21, 2018, 7:26am UTC](https://discuss.elastic.co/t/logstash-after-a-certain-amount-of-time-can-not-connect-to-the-database/145314/1 "2018-08-21T07:26:06Z")

</div>

I am using version 6.2.1 of logstash.  
Use jdbc input to read MSSQL data every hour and then send data to remote logstash.  
3-4 days work well. But after that I get the following error, but I have not found a reason yet.  
I changed the jdbc library and changed the jdbc\_validate\_connection setting, but I get the same error.

Does anyone have anybody who can help me?

logstash config.yml)

input {  
jdbc {  
jdbc\_driver\_library =\> "/data/logstash-6.2.1/lib/mssql-jdbc-6.4.0.jre8.jar"  
jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
jdbc\_connection\_string =\> "jdbc:sqlserver://xxx.xxx.xxx.xxx:xxxx;databaseName=xxx;user=xxxx;password=xxxx;"  
jdbc\_user =\> "xxxxx"  
jdbc\_password =\> "xxxxx"  
schedule =\> "\*/60 \* \* \* \*"  
add\_field =\> {  
"[fields][loc]" =\> "xxx"  
"[fields][title]" =\> "xxxxx"  
}  
parameters =\> {  
"nCode" =\> "xxxx"  
}  
statement =\> "EXEC [xxxx].[dbo].[xxxxx] 'xxxxx', :nCode, :sql\_last\_value"  
use\_column\_value =\> true  
jdbc\_validate\_connection =\> true  
tracking\_column =\> "xxxx"  
tracking\_column\_type =\> "numeric"  
last\_run\_metadata\_path =\> "file:///data/logstash-6.2.1/query/last\_run/xxxxx"  
}  
}  
output {  
tcp {  
host =\> "xxx.xxx.xxx.xxx"  
port =\> xxxx  
codec =\> "json\_lines"  
}  
}

log)

...  
[2018-08-21T10:02:53,233][INFO][logstash.inputs.jdbc] (4.238490s) EXEC [xxx].[dbo].[xxxxx] 'xxxx', N'xxx', N'xxxxxx' \<- So far, it works fine.

[2018-08-21T10:02:58,932][ERROR][logstash.inputs.jdbc] Unable to connect to database. Tried 1 times \<- At some point, an error occurs.{:error\_message=\>"Java::ComMicrosoftSqlserverJdbc::SQLServerException: Connection reset ClientConnectionId:c818c947-d26f-43e2-a738-235ef0ba6b1b"}  
[2018-08-21T10:02:58,932][ERROR][logstash.inputs.jdbc] Unable to connect to database. Tried 1 times {:error\_message=\>"Java::ComMicrosoftSqlserverJdbc::SQLServerException: Connection reset ClientConnectionId:fe018f0e-36ae-4d77-b26d-16ac3827cc28"}  
[2018-08-21T10:02:58,934][ERROR][logstash.inputs.jdbc] Unable to connect to database. Tried 1 times {:error\_message=\>"Java::ComMicrosoftSqlserverJdbc::SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Connection reset ClientConnectionId:d5946694-2fa9-40c9-8f17-fbee4af2167e"."}

---

<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:** [September 18, 2018, 7:26am UTC](https://discuss.elastic.co/t/logstash-after-a-certain-amount-of-time-can-not-connect-to-the-database/145314/2 "2018-09-18T07:26:06Z")

</div>

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