Search code examples
javamysqlmariadbprepared-statement

Java - Prepared Statement only works with one element for MySQL, otherwise it's working in MariaDB


I run a prepared statement to insert stuff in my database in batch. The code is working fine if we use MariaDB, but it's not when using MySQL.
I've tried to run the query manually with MySQL and it's working. Why is it not working in java ? Here is the query I use :

public final static String query = "INSERT INTO tableName (col1, col2) VALUES (?, ?);"

Solution

  • The issue was caused by the ; at the end of the query. It looks like the MySQL database is not handling well multiple insertions when the original query ends with ;