# Logstash can't read stored procedure statement as input

**URL:** <https://discuss.elastic.co/t/logstash-cant-read-stored-procedure-statement-as-input/239928>\
**Category:** Logstash\
**Created:** [July 5, 2020, 3:52pm UTC](https://discuss.elastic.co/t/logstash-cant-read-stored-procedure-statement-as-input/239928 "2020-07-05T15:52:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muhammad\_Badawy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muhammad_badawy/32/55529_2.png) [@Muhammad\_Badawy](https://discuss.elastic.co/u/Muhammad_Badawy)\
**Post date:** [July 5, 2020, 3:52pm UTC](https://discuss.elastic.co/t/logstash-cant-read-stored-procedure-statement-as-input/239928/1 "2020-07-05T15:52:48Z")

</div>

I'm trying to let logstash read from MySQL DB through stored procedure.  
Here is my config

```auto
input {
jdbc {
jdbc_driver_library => "/home/devops/mysql-connector-java-5.1.49/mysql-connector-java-5.1.49-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/abc"
jdbc_user => "kilany"
jdbc_password => "kilany"
statement_filepath => "/etc/logstash/conf.d/statement.txt"
}
}

filter {
mutate {
}

}
output {
stdout { codec => "rubydebug" }
}

```

* * *

and here is the statement:

```auto
SET @SQL= CONCAT('SELECT * from abc_inb_msg_',DATE_FORMAT(NOW(),'20%y%m%d'));
PREPARE stmt FROM @SQL;
EXECUTE stmt;

```

But I got the below error

```auto
[2020-07-05T18:38:00,601][ERROR][logstash.inputs.jdbc][main][b97add3b8c2d316a8513b35000848b54076b07556df746c5357b1f7c5e073835] Java::ComMysqlJdbcExceptionsJdbc4::MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PREPARE stmt FROM @SQL;
EXECUTE stmt' at line 2: SET @SQL= CONCAT('SELECT * from abc_inb_msg_',DATE_FORMAT(NOW(),'20%y%m%d'));
PREPARE stmt FROM @SQL;
EXECUTE stmt;

[2020-07-05T18:38:00,656][WARN][logstash.inputs.jdbc][main][b97add3b8c2d316a8513b35000848b54076b07556df746c5357b1f7c5e073835] Exception when executing JDBC query {:exception=>#<Sequel::DatabaseError: Java::ComMysqlJdbcExceptionsJdbc4::MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PREPARE stmt FROM @SQL;
EXECUTE stmt' at line 2>}

```

* * *

However no syntax error as the statement run successfully on MySQL client.  
Any one run logstash to receive from MYSQL DB through stored procedure can help?  
Logstash version 7.6

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:** [August 2, 2020, 3:52pm UTC](https://discuss.elastic.co/t/logstash-cant-read-stored-procedure-statement-as-input/239928/2 "2020-08-02T15:52:55Z")

</div>

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