Jdbc_streming and prepared statement

Hi ,

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

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) :

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):

[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

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