# Logstash 5.2 | Wanted to call jdbc statement(query) only when some external service/event hit to logstash like JMS

**URL:** https://discuss.elastic.co/t/logstash-5-2-wanted-to-call-jdbc-statement-query-only-when-some-external-service-event-hit-to-logstash-like-jms/169236
**Category:** Logstash
**Created:** [February 20, 2019, 2:31pm UTC](https://discuss.elastic.co/t/logstash-5-2-wanted-to-call-jdbc-statement-query-only-when-some-external-service-event-hit-to-logstash-like-jms/169236 "2019-02-20T14:31:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Satish\_Darade](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@Satish\_Darade](https://discuss.elastic.co/u/Satish_Darade)
#### Post date: [February 20, 2019, 2:31pm UTC](https://discuss.elastic.co/t/logstash-5-2-wanted-to-call-jdbc-statement-query-only-when-some-external-service-event-hit-to-logstash-like-jms/169236/1 "2019-02-20T14:31:52Z")

</div>

I am stuck in logstash input JDBC plugin. I am new to elasticsearch and I wanted to load data from database to elaststcsearch index using logstash.  
1st time I have successfully loaded database data into to elasticsearch index but when I run the update\_script.conf for update the index. For that, I have written schedule statement in update\_script.conf file.  
After every 5 seconds, It will hit to the database query and check if is there any update record available in the database then it will fetch data from the database and update/create the record in elasticsearch index. I have written below input code for that.

```
input { 
    jdbc { 
        jdbc_driver_library => "../../jt400.jar" 
        jdbc_driver_class => "com.ibm.as400.access.AS400JDBCDriver" 
        jdbc_connection_string => "jdbc:as400://X.X.X.X/zdbxabf005" 
        jdbc_user => "XXXXX" 
        jdbc_password => "XXXXXX"  
        type => "component"
        schedule => "*/5 * * * * *"
        statement =>"Database QUERY" 
  } 
} 

```

**Above script is making an unwanted call even the record is not updated in the database for every 5 seconds,** I don't want to make unwanted call DB statement for every 5 seconds. I wanted to call DB statements only when the record is updated in DB. for that we have written some JMS code in java application. Whenever a record is updated in the database JMS will send some events to logstash plugin (I don't know how to accept or identify this JMS external event in logstash).

I also wanted to know how to accept json data using JMS plugin.  
Could you please help me for the same.

---

<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 20, 2019, 2:32pm UTC](https://discuss.elastic.co/t/logstash-5-2-wanted-to-call-jdbc-statement-query-only-when-some-external-service-event-hit-to-logstash-like-jms/169236/2 "2019-03-20T14:32:06Z")

</div>

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