# Jdbc\_streming and prepared statement

**URL:** <https://discuss.elastic.co/t/jdbc-streming-and-prepared-statement/288647>\
**Category:** Logstash\
**Created:** [November 8, 2021, 2:56pm UTC](https://discuss.elastic.co/t/jdbc-streming-and-prepared-statement/288647 "2021-11-08T14:56:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roberto\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roberto_b/32/77615_2.png) [@Roberto\_B](https://discuss.elastic.co/u/Roberto_B)\
**Post date:** [November 8, 2021, 2:56pm UTC](https://discuss.elastic.co/t/jdbc-streming-and-prepared-statement/288647/1 "2021-11-08T14:56:21Z")

</div>

Hi ,

I'm trying to use a prepared statement in jdbc\_streaming filter, I setuped the prepared statement on mySql instance using this commands:

```auto
PREPARE lookup_persone FROM 'SELECT persone.id, persone.nome AS nome_persona,
                persone.cognome AS cognome_persona,
                persone.cod_fisc AS CF_persona,
                persone.sesso AS genere_persona,
                persone.data_nascita
                FROM persone where id = ?

```

Then I configured jdbc\_streaming filter, as the following (the event in bind\_values comes from the input) :

```auto
filter{
jdbc_streaming {
    jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/mysql-connector-java.jar"
    jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://ip-add.res:3306/test?zeroDateTimeBehavior=convertToNull&useUnicode=true&useJDBCCompliantTimezoneShift=true&useTimezone=true&useLegacyDatetimeCode=false&serverTimezone=UTC&cachePrepStmts=true&prepStmtCacheSize=250&prepStmtCacheSqlLimit=2048&useServerPrepStmts=true"
    jdbc_user => ":-D"
    jdbc_password => ":-D"
    use_prepared_statements => true
    prepared_statement_name => "lookup_persone"
    statement => "SELECT persone.id, persone.nome AS nome_persona,
                persone.cognome AS cognome_persona,
                persone.cod_fisc AS CF_persona,
                persone.sesso AS genere_persona,
                persone.data_nascita
                FROM persone where id = ?"
    prepared_statement_bind_values => ["[:id_persona]"]
    target => "persone"
        }
}

```

The result? Nothing. Seems like the parameter that comes from input is a nil (actually **is not** a null value but an integer):

```auto
[DEBUG] 2021-11-08 15:37:39.313 [[main]>worker0] preparedstatementhandler - Executing JDBC query {:statement=>"SELECT persone.id, persone.nome AS nome_persona,\n persone.cognome AS cognome_persona,\n persone.cod_fisc AS CF_persona,\n persone.sesso AS genere_persona,\n persone.data_nascita\n FROM persone where id = ?", :parameters=>{:p0=>nil}}

```

Any Ideas? I'm going crazy (using normal statement, without prepared\_statement in other words, it works properly).

Roberto

---

<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 6, 2021, 2:57pm UTC](https://discuss.elastic.co/t/jdbc-streming-and-prepared-statement/288647/2 "2021-12-06T14:57:16Z")

</div>

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