# Duplication of rows in jdbc logstash input - Using stored procedure

**URL:** https://discuss.elastic.co/t/duplication-of-rows-in-jdbc-logstash-input-using-stored-procedure/168803
**Category:** Logstash
**Created:** [February 18, 2019, 10:24am UTC](https://discuss.elastic.co/t/duplication-of-rows-in-jdbc-logstash-input-using-stored-procedure/168803 "2019-02-18T10:24:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Giripratap\_Singh](https://avatars.discourse-cdn.com/v4/letter/g/d9b06d/32.png) [@Giripratap\_Singh](https://discuss.elastic.co/u/Giripratap_Singh)
#### Post date: [February 18, 2019, 10:24am UTC](https://discuss.elastic.co/t/duplication-of-rows-in-jdbc-logstash-input-using-stored-procedure/168803/1 "2019-02-18T10:24:45Z")

</div>

I'm fetching data from jdbc input plugin. After running through the whole procedure logstash stops.

Problem is whenever the new rows are added, I run the .conf file and it duplicates the previous data. I have read only access to the database and I call a procedure to fetch the data.

SQL Query - "CALL `faredge`.`transaction_data`('2015-01-21 12:30:00','2019-02-11 18:29:00');"

faredge is my schema and transaction\_data is my stored procedure name

CONTENTS OF conf file:  
input {  
jdbc {  
jdbc\_connection\_string =\> "jdbc:mysql://172.23.125.52:3304/faredge"

```
    jdbc_user => "faredge"
    jdbc_password => "faredge"
	jdbc_driver_library => "C:\Users\giripratap.shekhawat.NUCDOMAIN\Downloads\mysql-connector-java-5.1.47\mysql-connector-java-5.1.47\mysql-connector-java-5.1.47-bin.jar"
    jdbc_driver_class => "Java::com.mysql.jdbc.Driver"
	statement => "CALL `faredge`.`transaction_data`('2015-01-21 12:30:00','2019-02-11 18:29:00');"
}

```

}  
filter {  
mutate {  
convert =\> {  
"mobile\_no" =\> "string"  
}  
}   
}

output {  
stdout {  
codec =\> json  
}   
elasticsearch {  
hosts =\> ["10.0.51.128:9200"]  
index =\> "payse\_new\_transac"  
retry\_on\_conflict =\> 5  
}  
}

---

<div class="post-metadata">

### Author: ![pjanzen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pjanzen/32/13756_2.png) [@pjanzen](https://discuss.elastic.co/u/pjanzen)
#### Post date: [February 18, 2019, 12:19pm UTC](https://discuss.elastic.co/t/duplication-of-rows-in-jdbc-logstash-input-using-stored-procedure/168803/2 "2019-02-18T12:19:51Z")

</div>

Hi,

When you have new rows do you change the query to reflect that? If you would run the query twice it will push the events to elasticsearch again which would look like duplicates.

So, what you want to do it make sure when new rows are added, you only pull those rows in your query.

Paul.

---

<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: [March 18, 2019, 12:19pm UTC](https://discuss.elastic.co/t/duplication-of-rows-in-jdbc-logstash-input-using-stored-procedure/168803/3 "2019-03-18T12:19:52Z")

</div>

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