# How to get JDBC Data from Multiple Queries

**URL:** <https://discuss.elastic.co/t/how-to-get-jdbc-data-from-multiple-queries/25631>\
**Category:** Logstash\
**Created:** [July 15, 2015, 1:20pm UTC](https://discuss.elastic.co/t/how-to-get-jdbc-data-from-multiple-queries/25631 "2015-07-15T13:20:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kintas](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kintas](https://discuss.elastic.co/u/Kintas)\
**Post date:** [July 15, 2015, 1:20pm UTC](https://discuss.elastic.co/t/how-to-get-jdbc-data-from-multiple-queries/25631/1 "2015-07-15T13:20:56Z")

</div>

Hello,

I'm trying to collect data from a DB (Derby, MySQL, Oracle) and my Schema is like this:

![](https://us1.discourse-cdn.com/elastic/original/2X/5/525e18a8592559be210749ef32eeff9e6fa870ac.png)

the main table is "exchange" and I need to get data from all other tables.  
I'm trying to use logstash-input-jdbc, but with this input I can only configure one query and because the relations between the tables are 1-\>N, I can't collect all the data I need.

My goal is in the final to get something like this:

```
{
   ExchangeId => "",
   Role => "",
   EndPointService => "",
   ...
   exchangeproperty => [
                                     {
                                        ExchangeId => "",
                                        Name => "",
                                        Value => "",
                                     },
                                     { ... }, ...
                                   ]
  normalizemessage => [.....]
}

```

At first, I thought to build a new Filter Plugin. My idea was, configure the logstash-input-jdbc plugin to Select the main table, and then with my new Filter Plugin, make all other queries with the ExchangeId return from Input.  
When I try to implment my ideia, I follow this [tutorial](https://www.elastic.co/guide/en/logstash/current/_how_to_write_a_logstash_filter_plugin.html), but when I try to "bundle install" I'm getting the following error:

```
There was a NoMethodError while loading logstash-filter-jdbc.gemspec: 
undefined method `metadata=' for #<Gem::Specification name=logstash-filter-jdbc
version=0.0.1> from
/home/kintas/RubymineProjects/logstash-filter-jdbc/logstash-filter-jdbc.gemspec:18:in
`block in <main>'

```

I also try to build a new Input Plugin but I'm getting the same error.

So, what is the best way to accomplish my Goal? A new filter plugin, a new input plugin or other plugin that allready exists?

Thanks,  
Kintas

---

<div class="post-metadata">

**Author:** ![talevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talevy/32/44896_2.png) [@talevy](https://discuss.elastic.co/u/talevy)\
**Post date:** [July 21, 2015, 7:06pm UTC](https://discuss.elastic.co/t/how-to-get-jdbc-data-from-multiple-queries/25631/2 "2015-07-21T19:06:54Z")

</div>

would you mind sharing your gemspec for this filter?

I would take a look at some other plugin's gemspec and following that.

---

<div class="post-metadata">

**Author:** ![Kintas](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kintas](https://discuss.elastic.co/u/Kintas)\
**Post date:** [July 22, 2015, 9:15am UTC](https://discuss.elastic.co/t/how-to-get-jdbc-data-from-multiple-queries/25631/3 "2015-07-22T09:15:53Z")

</div>

@talevy

I error I previous report was because my Ruby version was 1.9.1  
After installing version 2.2.2p95 this error disapear.

But when I try 'bundle install' some gems couldn't be found.

"kintas@Kamaleon:~/RubymineProjects/logstash-filter-jdbc$ bundle install  
Fetching gem metadata from [https://rubygems.org/](https://rubygems.org/)..........  
Fetching version metadata from [https://rubygems.org/](https://rubygems.org/)...  
Fetching dependency metadata from [https://rubygems.org/](https://rubygems.org/)..  
Could not find gem 'logstash-devutils (\>= 0) ruby' in any of the gem sources  
listed in your Gemfile or available on this machine.  
"  
you can get the gemfile in "[https://github.com/GrupoFirst/logstash-input-jdbc](https://github.com/GrupoFirst/logstash-input-jdbc)"

thanks

---

<div class="post-metadata">

**Author:** ![talevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talevy/32/44896_2.png) [@talevy](https://discuss.elastic.co/u/talevy)\
**Post date:** [July 28, 2015, 10:04pm UTC](https://discuss.elastic.co/t/how-to-get-jdbc-data-from-multiple-queries/25631/4 "2015-07-28T22:04:08Z")

</div>

JRuby is required for this plugin.

---

<div class="post-metadata">

**Author:** ![endersonmaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/endersonmaia/32/17308_2.png) [@endersonmaia](https://discuss.elastic.co/u/endersonmaia)\
**Post date:** [May 15, 2017, 1:59pm UTC](https://discuss.elastic.co/t/how-to-get-jdbc-data-from-multiple-queries/25631/5 "2017-05-15T13:59:46Z")

</div>

Hello @Kintas, I know it's an old thread, but you can achieve this with jdbc-streaming plugin.

I have a situation like yours, and I'm using jdbc-input to get the main data, and jdbc-streaming to enhance the message with more data.

---

<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:** [July 6, 2017, 4:26am UTC](https://discuss.elastic.co/t/how-to-get-jdbc-data-from-multiple-queries/25631/6 "2017-07-06T04:26:35Z")

</div>


