1. Create a connection with enabled rewriteBatchedStatements=true
2. Use the following code to reproduce the issue:
For any error we are expecting valid message, for example: java.sql.BatchUpdateException: (conn=86322) Table 'test.table1' doesn't exist
Some unexpected message appears: java.sql.BatchUpdateException: (conn=86341) Error reading results 2
I made some analysis and found that this unexpected messae is coming from the class org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol#executeBatchMulti method handleResultException and it cause ArrayIndexOutOfBoundException when it tries to build error message. See attached screenshot, with explanation, why there's ArrayIndexOutOfBoundException. For some reasons paramCount was defined as 4, but actually query has only 2 parameters.
NOTE: When I remove the last semicolon in the query - it is working as expected.