# Not able to run ALTER query through logstash JDBC plugin

**URL:** <https://discuss.elastic.co/t/not-able-to-run-alter-query-through-logstash-jdbc-plugin/352072>\
**Category:** Logstash\
**Created:** [January 30, 2024, 9:18am UTC](https://discuss.elastic.co/t/not-able-to-run-alter-query-through-logstash-jdbc-plugin/352072 "2024-01-30T09:18:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpraveenr](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@rpraveenr](https://discuss.elastic.co/u/rpraveenr)\
**Post date:** [January 30, 2024, 9:18am UTC](https://discuss.elastic.co/t/not-able-to-run-alter-query-through-logstash-jdbc-plugin/352072/1 "2024-01-30T09:18:06Z")

</div>

I am not able to run `ALTER` queries on my Oracle database through Logstash. Below is the snippet from the config file:

```auto
input {
    jdbc {
        jdbc_validate_connection => true
        jdbc_driver_library => "ojdbc7.jar"
        jdbc_driver_class => "Java::oracle.jdbc.OracleDriver"
        jdbc_connection_string => "jdbc:oracle:thin:@<hostname>:<port>/<SID>"
        jdbc_user => "username"
        jdbc_password => "password"
        schedule => "48 11 * * thu"
        statement => "ALTER INDEX <tablename> REBUILD ONLINE"
    }
}

```

Getting error:  
`Exception when executing JDBC query {:exception=>Java::JavaSql::SQLRecoverableException, :message=>"Closed Connection"}`

The same config is working fine if I run a `select` query and I am able to see the logs in Kibana. Also, I am able to execute the `ALTER` query through SQL Developer tool with same user that I am passing here. So this means there's no access related issues.

Is this even possible to run `ALTER` queries through Logstash? Not sure what I am missing here. Any help on this is appreciated. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 30, 2024, 9:47am UTC](https://discuss.elastic.co/t/not-able-to-run-alter-query-through-logstash-jdbc-plugin/352072/2 "2024-01-30T09:47:57Z")

</div>

The jdbc input is meant to generate events from the database. Not to send admin commands. Why are you doing this?

---

<div class="post-metadata">

**Author:** ![rpraveenr](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@rpraveenr](https://discuss.elastic.co/u/rpraveenr)\
**Post date:** [January 30, 2024, 10:36am UTC](https://discuss.elastic.co/t/not-able-to-run-alter-query-through-logstash-jdbc-plugin/352072/3 "2024-01-30T10:36:54Z")

</div>

Due to some technical constraint on the infra where my database is created, I am not able to run these queries in an automated way through tools like Jenkins.  
That's when I thought of exploring Logstash to achieve this. This is one of the few options that I have in mind.

Is it not possible at all through Logstash?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 30, 2024, 10:52am UTC](https://discuss.elastic.co/t/not-able-to-run-alter-query-through-logstash-jdbc-plugin/352072/4 "2024-01-30T10:52:19Z")

</div>

That's not the tool for this IMHO. And I believe the error you are seeing here is similar to what you might be seeing from Jenkins or other tools like this.  
You should better ask your DBA.

---

<div class="post-metadata">

**Author:** ![rpraveenr](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@rpraveenr](https://discuss.elastic.co/u/rpraveenr)\
**Post date:** [January 31, 2024, 6:27am UTC](https://discuss.elastic.co/t/not-able-to-run-alter-query-through-logstash-jdbc-plugin/352072/5 "2024-01-31T06:27:24Z")

</div>

Thanks for the reply. I shall check for another approach.

---

<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 28, 2024, 6:28am UTC](https://discuss.elastic.co/t/not-able-to-run-alter-query-through-logstash-jdbc-plugin/352072/6 "2024-02-28T06:28:18Z")

</div>

Closed on February 28, 2024, 6:28am UTC

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