# Jdbc: record\_last\_run always saves 2017-01-01 as last run date

**URL:** https://discuss.elastic.co/t/jdbc-record-last-run-always-saves-2017-01-01-as-last-run-date/85972
**Category:** Logstash
**Created:** [May 16, 2017, 3:41pm UTC](https://discuss.elastic.co/t/jdbc-record-last-run-always-saves-2017-01-01-as-last-run-date/85972 "2017-05-16T15:41:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sivabalan19](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@sivabalan19](https://discuss.elastic.co/u/sivabalan19)
#### Post date: [May 16, 2017, 3:41pm UTC](https://discuss.elastic.co/t/jdbc-record-last-run-always-saves-2017-01-01-as-last-run-date/85972/1 "2017-05-16T15:41:52Z")

</div>

Hi ,

I am using Logstash 5.4.0. Trying to pull all the new records that are in my Db after my last run. Below is my configuration. However, I am finding the content of the file mentioned in last\_run\_metadata\_path always revert back to "--- 2017-01-01 00:00:00.000000000 Z" after each run. It looks like it is not storing the time when schedular has run last time. Just to add, my tracking\_column's type is timestamp and i have mentioned the same in configuration sql statement also (but for now i have masked it).  
Because of this, i m getting duplicates from output. ☹ Help me please.

input {  
jdbc {  
type =\> "Database"  
sql\_log\_level =\> "debug"  
jdbc\_driver\_library =\> "/home/siva/Oracle/engine/logstash-5.4.0/vendor/ojdbc7.jar"  
jdbc\_driver\_class =\> "Java::oracle.jdbc.driver.OracleDriver"  
jdbc\_connection\_string =\> "jdbc:oracle:thin:@localhost:1521/XE"  
jdbc\_user =\> "XXXX"  
jdbc\_password =\> "XXXX"  
statement =\> "\*\*\*\*\*"  
use\_column\_value =\> true  
tracking\_column =\> "insert\_time"  
tracking\_column\_type =\> "timestamp"  
schedule =\> "\* \* \* \* \*"  
record\_last\_run =\> true  
last\_run\_metadata\_path =\> "/home/siva/Oracle/engine/logstash-5.4.0/bin/logstash\_jdbc\_last\_run"  
}  
}

output {  
stdout {  
codec =\> json  
}  
}

---

<div class="post-metadata">

### Author: ![sivabalan19](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@sivabalan19](https://discuss.elastic.co/u/sivabalan19)
#### Post date: [May 18, 2017, 8:56pm UTC](https://discuss.elastic.co/t/jdbc-record-last-run-always-saves-2017-01-01-as-last-run-date/85972/2 "2017-05-18T20:56:17Z")

</div>

Can someone please help me here . ☹

---

<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: [May 19, 2017, 11:11am UTC](https://discuss.elastic.co/t/jdbc-record-last-run-always-saves-2017-01-01-as-last-run-date/85972/3 "2017-05-19T11:11:43Z")

</div>

When you set `use_column_value => true` then **sql\_last\_value** becomes the value of the tracking column from each record as it is processed and the last record wins (and is persisted). In this case make sure that the query has an `ORDER BY insert_time` clause. Make sure that you have a field called `insert_time` in your SELECT clause. Surely not all `insert_time` values are "2017-01-01 00:00:00.000000000 Z"?.

When you set it to false then the sql\_last\_value becomes a timestamp taken at the time just before the query is run and that value is persisted at the end of the run.

---

<div class="post-metadata">

### Author: ![sivabalan19](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@sivabalan19](https://discuss.elastic.co/u/sivabalan19)
#### Post date: [May 19, 2017, 12:45pm UTC](https://discuss.elastic.co/t/jdbc-record-last-run-always-saves-2017-01-01-as-last-run-date/85972/4 "2017-05-19T12:45:39Z")

</div>

@guyboertje Thanks for that. It helped. I am able to find the last run date-time in the file now.  
Appreciate your help.

-thanks,  
Siva V

---

<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: [June 16, 2017, 12:45pm UTC](https://discuss.elastic.co/t/jdbc-record-last-run-always-saves-2017-01-01-as-last-run-date/85972/5 "2017-06-16T12:45:40Z")

</div>

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