# I am trying to pass a fieldname in jdbc\_streaming plugin to the jdbc\_user parameter, but it fails to read the value of the field

**URL:** <https://discuss.elastic.co/t/i-am-trying-to-pass-a-fieldname-in-jdbc-streaming-plugin-to-the-jdbc-user-parameter-but-it-fails-to-read-the-value-of-the-field/283241>\
**Category:** Logstash\
**Created:** [September 3, 2021, 6:23am UTC](https://discuss.elastic.co/t/i-am-trying-to-pass-a-fieldname-in-jdbc-streaming-plugin-to-the-jdbc-user-parameter-but-it-fails-to-read-the-value-of-the-field/283241 "2021-09-03T06:23:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Varsha1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varsha1/32/78067_2.png) [@Varsha1](https://discuss.elastic.co/u/Varsha1)\
**Post date:** [September 3, 2021, 6:23am UTC](https://discuss.elastic.co/t/i-am-trying-to-pass-a-fieldname-in-jdbc-streaming-plugin-to-the-jdbc-user-parameter-but-it-fails-to-read-the-value-of-the-field/283241/1 "2021-09-03T06:23:41Z")

</div>

```auto
jdbc_streaming {
	jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
	jdbc_driver_library => "/home/user/logstash-7.14.0/logstash-core/lib/jars/ojdbc8.jar"
	jdbc_connection_string => "jdbc:oracle:thin:@XXXXX"
	jdbc_user => "%{jdbc_username}"
	jdbc_password => "XXXXX"
}

```

---

<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:** [September 3, 2021, 2:56pm UTC](https://discuss.elastic.co/t/i-am-trying-to-pass-a-fieldname-in-jdbc-streaming-plugin-to-the-jdbc-user-parameter-but-it-fails-to-read-the-value-of-the-field/283241/2 "2021-09-03T14:56:48Z")

</div>

> [@Varsha1](#):
>
> `jdbc_user => "%{jdbc_username}"`

This will not work. The connection is setup and authenticated when the plugin is initialized. The [code](https://github.com/logstash-plugins/logstash-filter-jdbc_streaming/blob/2ed23b51c0b9b1a57e39bf672f6f013eae88d5fc/lib/logstash/plugin_mixins/jdbc_streaming.rb#L85) does not sprintf the jdbc\_user option because there is no event to refer to at that point.

---

<div class="post-metadata">

**Author:** ![Varsha1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varsha1/32/78067_2.png) [@Varsha1](https://discuss.elastic.co/u/Varsha1)\
**Post date:** [September 4, 2021, 5:17am UTC](https://discuss.elastic.co/t/i-am-trying-to-pass-a-fieldname-in-jdbc-streaming-plugin-to-the-jdbc-user-parameter-but-it-fails-to-read-the-value-of-the-field/283241/3 "2021-09-04T05:17:10Z")

</div>

Thanks Badger, is there a way to pass credentials programmatically to this plugin?

---

<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:** [September 4, 2021, 4:36pm UTC](https://discuss.elastic.co/t/i-am-trying-to-pass-a-fieldname-in-jdbc-streaming-plugin-to-the-jdbc-user-parameter-but-it-fails-to-read-the-value-of-the-field/283241/4 "2021-09-04T16:36:41Z")

</div>

You can probably use environment variables. I would expect them to get substituted at configuration time.

---

<div class="post-metadata">

**Author:** ![Varsha1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varsha1/32/78067_2.png) [@Varsha1](https://discuss.elastic.co/u/Varsha1)\
**Post date:** [September 5, 2021, 5:07am UTC](https://discuss.elastic.co/t/i-am-trying-to-pass-a-fieldname-in-jdbc-streaming-plugin-to-the-jdbc-user-parameter-but-it-fails-to-read-the-value-of-the-field/283241/5 "2021-09-05T05:07:31Z")

</div>

It worked Badger, 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:** [October 3, 2021, 5:08am UTC](https://discuss.elastic.co/t/i-am-trying-to-pass-a-fieldname-in-jdbc-streaming-plugin-to-the-jdbc-user-parameter-but-it-fails-to-read-the-value-of-the-field/283241/6 "2021-10-03T05:08:11Z")

</div>

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