# JDBC update issue

**URL:** <https://discuss.elastic.co/t/jdbc-update-issue/116157>\
**Category:** Logstash\
**Created:** [January 19, 2018, 4:23am UTC](https://discuss.elastic.co/t/jdbc-update-issue/116157 "2018-01-19T04:23:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavuk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pavuk/32/28914_2.png) [@pavuk](https://discuss.elastic.co/u/pavuk)\
**Post date:** [January 19, 2018, 4:23am UTC](https://discuss.elastic.co/t/jdbc-update-issue/116157/1 "2018-01-19T04:23:20Z")

</div>

Hi,

At the moment I have following configuration

```
input {
  jdbc {
    jdbc_driver_library => "/usr/share/java/mysql-connector-java.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/xf"
    jdbc_user => "xxxx"
    jdbc_password => "xxxxx"
    schedule => "0 * * * *"
    statement => "select xf_post.username, count(*) as posts, count(xf_thread.best_answer_id) as best_answers, sum(xf_post.likes) as likes from xf_post left join xf_thread on (xf_post.post_id = xf_thread.best_answer_id and xf_thread.best_answer_id > 0) where xf_post.post_date between UNIX_TIMESTAMP('2018-01-01 00:00:00') and UNIX_TIMESTAMP('2018-02-01 00:00:00') group by xf_post.username order by posts desc limit 25"
}
}
output {
 elasticsearch {
   hosts => ["http://xxxx.com:9200/"]
   user => logstash_internal
   password => xxxx
   index => "forum_stat"
   document_type => "forum_stat"
   document_id => "%{id}"
 }
# stdout { codec => rubydebug }
}

```

Problem in that records in ES index are duplicated and the second problem in that I want to use 1 month period in my SQL query (xf\_post.post\_date between UNIX\_TIMESTAMP('2018-01-01 00:00:00') and UNIX\_TIMESTAMP('2018-02-01 00:00:00')) and I don't know how to make it automatically without changing this period in config manually and removing index each month.

Please help me with it.

Thanks

---

<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 16, 2018, 4:23am UTC](https://discuss.elastic.co/t/jdbc-update-issue/116157/2 "2018-02-16T04:23:40Z")

</div>

Closed on February 16, 2018, 4:23am UTC

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