# Query OK in JDBC\_Stream But Not In JDBC\_Static?

**URL:** <https://discuss.elastic.co/t/query-ok-in-jdbc-stream-but-not-in-jdbc-static/290362>\
**Category:** Logstash\
**Created:** [November 28, 2021, 1:18pm UTC](https://discuss.elastic.co/t/query-ok-in-jdbc-stream-but-not-in-jdbc-static/290362 "2021-11-28T13:18:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rojin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rojin/32/97697_2.png) [@rojin](https://discuss.elastic.co/u/rojin)\
**Post date:** [November 28, 2021, 1:18pm UTC](https://discuss.elastic.co/t/query-ok-in-jdbc-stream-but-not-in-jdbc-static/290362/1 "2021-11-28T13:18:37Z")

</div>

Hey, I have a query which works fine while using the JDBC steam " **statement**" but it does not seem to work while using JDBC static.  
Here's my JDBC\_Stream configuration:

```auto
filter {
  jdbc_streaming {
    jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://<address>:<port>/<db>"
    jdbc_user => "user"
    jdbc_password => "password"
    statement => "SELECT name FROM db_table WHERE inet_aton(?) between ip_from_int and ip_to_int limit 1"
    use_prepared_statements => true
    prepared_statement_name => "the_info"
    prepared_statement_bind_values => ["[clientip]"]
    target => "result"

    add_field => { isp_name => "%{[result][0][name]}" }
    remove_field => ["result"]
  }
}

```

And here's my JDBC\_Static configuration:

```auto
filter {
  jdbc_static {
    loaders => [
      {
        id => "my_table"
        query => "select ip_from_int, ip_to_int, name from ip_ranges"
        local_table => "my_table"
       }
    ]
    local_db_objects => [
      {
        name => "my_table"
        columns => [
          ["ip_from_int", "INT(10)"],
          ["ip_to_int", "INT(10)"],
          ["name", "VARCHAR(255)"]
        ]
      }
    ]
    local_lookups => [
      {
        query => "SELECT name FROM db_table WHERE inet_aton(?) between ip_from_int and ip_to_int limit 1"
        prepared_parameters => ["[clientip]"]
        target => "result"
      }
    ]
    add_field => { result_name => "%{[result][0][name]}" }
    remove_field => ["result"]

    loader_schedule => "0 */2 * * *"
    jdbc_user => "user"
    jdbc_password => "password"
    jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://<address>:<port>/<db>"
    staging_directory => "/var/logstash/jdbc_static/import_data/"
  }
 }

```

I'd be glad if anyone could help!

---

<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:** [November 28, 2021, 3:03pm UTC](https://discuss.elastic.co/t/query-ok-in-jdbc-stream-but-not-in-jdbc-static/290362/2 "2021-11-28T15:03:16Z")

</div>

> [@rojin](#):
>
> `SELECT name FROM db_table WHERE inet_aton(?) between ip_from_int and ip_to_int limit 1`

A jdbc\_streaming filter executes a query against a database using JDBC. So the query can use anything that that database (MySQL) supports.

A jdbc\_static filter builds a Derby in-memory database from the results of the loaders. You might be able to use inet\_aton in the loader, but Derby does not support it, so you cannot use it in the query.

---

<div class="post-metadata">

**Author:** ![rojin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rojin/32/97697_2.png) [@rojin](https://discuss.elastic.co/u/rojin)\
**Post date:** [November 28, 2021, 4:55pm UTC](https://discuss.elastic.co/t/query-ok-in-jdbc-stream-but-not-in-jdbc-static/290362/3 "2021-11-28T16:55:20Z")

</div>

Thanks; I was not aware of that. Is there a solution to be able to use inet\_aton()? Something similar?

---

<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:** [November 28, 2021, 5:29pm UTC](https://discuss.elastic.co/t/query-ok-in-jdbc-stream-but-not-in-jdbc-static/290362/4 "2021-11-28T17:29:40Z")

</div>

I cannot think of a way to do that in a jdbc\_static filter.

---

<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:** [December 26, 2021, 5:30pm UTC](https://discuss.elastic.co/t/query-ok-in-jdbc-stream-but-not-in-jdbc-static/290362/5 "2021-12-26T17:30:19Z")

</div>

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