# Unique entries in JDBC

**URL:** <https://discuss.elastic.co/t/unique-entries-in-jdbc/163415>\
**Category:** Logstash\
**Created:** [January 8, 2019, 5:40pm UTC](https://discuss.elastic.co/t/unique-entries-in-jdbc/163415 "2019-01-08T17:40:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kb2295](https://avatars.discourse-cdn.com/v4/letter/k/4491bb/32.png) [@kb2295](https://discuss.elastic.co/u/kb2295)\
**Post date:** [January 8, 2019, 5:40pm UTC](https://discuss.elastic.co/t/unique-entries-in-jdbc/163415/1 "2019-01-08T17:40:33Z")

</div>

Hello,

I'm trying to create an Elasticsearch index using JDBC plugin to read data from SQL Server. I have configured it to read my data at 2AM every day.

However, what happens if the system goes down at 2:05AM, having read only half the data, and restarts and hour later?  
Does this mean I will have duplicate data for the first half (aka the data that was indexed between 2 and 2:05)?

What should I do to avoid a situation like this? I read a bit on states (sql\_last\_start) but I don't quite understand it.

Would adding a unique document ID be helpful?

This is my config file:

> input {  
> jdbc {  
> jdbc\_connection\_string =\> "jdbc:sqlserver://mswpffussqua:2431;databaseName=abc"  
> jdbc\_user =\> "abc"  
> jdbc\_validate\_connection =\> true  
> jdbc\_driver\_library =\> "/path/to/jar/file/sqljdbc4-4.0.jar"  
> jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
> statement =\> "select \* from dbo.tb\_Account"  
> schedule =\> "0 2 \* \* \*"  
> }  
> }  
> output {  
> elasticsearch {  
> hosts=\> ["host1","host2"]  
> index =\> "jdbc"  
> user =\> xxx  
> password =\> xxxx  
> ssl =\> true  
> ssl\_certificate\_verification =\> false  
> cacert =\> '/path/to/ca.crt'  
> }  
> stdout {}  
> }

Thank you in advanced!

---

<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:** [February 5, 2019, 5:40pm UTC](https://discuss.elastic.co/t/unique-entries-in-jdbc/163415/2 "2019-02-05T17:40:41Z")

</div>

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