# Using jdbc\_static to build connectionstring that are used in later step

**URL:** <https://discuss.elastic.co/t/using-jdbc-static-to-build-connectionstring-that-are-used-in-later-step/341189>\
**Category:** Logstash\
**Created:** [August 20, 2023, 5:26pm UTC](https://discuss.elastic.co/t/using-jdbc-static-to-build-connectionstring-that-are-used-in-later-step/341189 "2023-08-20T17:26:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johanwallenborg](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@johanwallenborg](https://discuss.elastic.co/u/johanwallenborg)\
**Post date:** [August 20, 2023, 5:26pm UTC](https://discuss.elastic.co/t/using-jdbc-static-to-build-connectionstring-that-are-used-in-later-step/341189/1 "2023-08-20T17:26:26Z")

</div>

I found and read about jdbc\_static and trying to get my head around.

But I have some questions before i dive deeper into this one.

Say that I have a database with a table with rows that contains i.e a identifier, database-server and database-name, then i use jdbc\_static-filter and load that data into memory. Would it be possible to iterate that data and build another connectionstring that is used with the jdbc-input to fetch other data with given sql-query?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 20, 2023, 5:55pm UTC](https://discuss.elastic.co/t/using-jdbc-static-to-build-connectionstring-that-are-used-in-later-step/341189/2 "2023-08-20T17:55:00Z")

</div>

> [@johanwallenborg](#):
>
> Would it be possible to iterate that data and build another connectionstring that is used with the jdbc-input to fetch other data with given sql-query?

Possible? Maybe. Practicable? No!

The connection string for a jdbc input or jdbc\_streaming filter has to be set when the pipeline is started. It cannot reference fields on an event since no events exist at that point. It can [reference](https://www.elastic.co/guide/en/logstash/current/environment-variables.html) an environment variable.

So you would have to start a new instance of logstash for each connection string you wanted to use, which would be ridiculously expensive.

Also you cannot iterate over the data in a jdbc\_static filter, you can just do lookups against it.

If you have a DB table that lists the databases you need to run a query against then I would start with ksh and an SQLtool.

---

<div class="post-metadata">

**Author:** ![johanwallenborg](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@johanwallenborg](https://discuss.elastic.co/u/johanwallenborg)\
**Post date:** [August 20, 2023, 7:17pm UTC](https://discuss.elastic.co/t/using-jdbc-static-to-build-connectionstring-that-are-used-in-later-step/341189/3 "2023-08-20T19:17:02Z")

</div>

> [@Badger](#):
>
> If you have a DB table that lists the databases you need to run a query against then I would start with ksh and an SQLtool.

Yep. I thought about something similiar first but then I read about this jdbc\_static and what it could so I thought i would be able to get rid of extra tools. I'm happy I asked 🙂

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:** [September 17, 2023, 7:17pm UTC](https://discuss.elastic.co/t/using-jdbc-static-to-build-connectionstring-that-are-used-in-later-step/341189/4 "2023-09-17T19:17:23Z")

</div>

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