# JDBC input plugin

**URL:** <https://discuss.elastic.co/t/jdbc-input-plugin/149070>\
**Category:** Logstash\
**Created:** [September 19, 2018, 7:39am UTC](https://discuss.elastic.co/t/jdbc-input-plugin/149070 "2018-09-19T07:39:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goyal.vikas87](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@Goyal.vikas87](https://discuss.elastic.co/u/Goyal.vikas87)\
**Post date:** [September 19, 2018, 7:39am UTC](https://discuss.elastic.co/t/jdbc-input-plugin/149070/1 "2018-09-19T07:39:39Z")

</div>

I am using below configuration in jdbc input:

Use\_column\_value = true  
Tracking\_column = end\_dt (timestamp field)

I have some records in table where end\_dt value is null showing that job is in running status. But when I run the config file it does not pick records where value is null as jdbc\_last\_run contains timestamp value.

Status will be updated for these records when end\_dt value will be updated instead of null.

Please help how can I pick null value records showing running jobs and also update the status later on when end\_dt value is updated.

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [September 25, 2018, 2:03pm UTC](https://discuss.elastic.co/t/jdbc-input-plugin/149070/2 "2018-09-25T14:03:18Z")

</div>

You probably need two jdbc inputs:

1. having `WHERE end_dt IS NULL` and `type => end_dt_unset`
2. having `WHERE end_dt > :sql_last_value ORDER BY end_dt` and `type => end_dt_set`

Are you using Elasticsearch?

If so, have a conditional for one es output that bulk inserts `end_dt_unset` events with a doc\_id and another conditional for another es output that updates the doc by id.

```auto
outputs {
  if [type] == "end_dt_unset" {

  }
  if [type] == "end_dt_set" {

  }
}

```

Do not put the two jdbc inputs on the same schedule. Perhaps put the NULL one on 15,30,45 seconds and the not NULL one on each minute at the 0 second mark. This gives LS/ES time to to index and make searchable the NULL ones.

From an ES mapping point of view, for the NULL doc cases, in the SELECT clause, set the `end_dt` to a timestamp literal of your choosing.

---

<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:** [October 23, 2018, 2:03pm UTC](https://discuss.elastic.co/t/jdbc-input-plugin/149070/3 "2018-10-23T14:03:32Z")

</div>

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