Description
I'm using this JDBC driver in the Apache Incubator Guacamole project, with MyBatis and Guice, to try to make the SQLite database available as an authentication back-end for the product. In a couple of places in the code (1, 2), there are prepared statements passed to the JDBC drivers that contain multiple select statements from different tables, each terminated by a semicolon. This allows the Java code to make a single method call that runs both queries and returns a single result map, and keeps the code simple. It works perfectly fine for MySQL, PostgreSQL, and SQL Server, but generates this ArrayIndexOutOfBoundsException when used with this SQLite JDBC driver.
When the batch array is allocated in the CorePreparedStatement class, it's allocated based on the number of parameters. However, when multiple select statements are used that expect the same parameters to be passed, there will be x * y number of positions, where x is the parameter count and y is the number of SELECT statements, which is what results in the index out of bounds exception.
I'm not sure if batch needs to be dynamically allocated or resized, or if the size that it needs to be can be computed from other available parameters to get the total position count, but the current method does not allow for multiple statements to be prepared properly.