Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Chris Calender reports :
There is a bug in the current release of the MariaDB Java Client v1.1.2 with usage of MySQL Server in version 5.5.25a
If using prepared statements with parameters the call of PreparedStatement#getMetaData() always fails with an Exception.
PreparedStatement#getMetaData() fails if the query contains at least one '?' for a parameter.
This error can be reproduced simply by executing the TestSQL Java class attached to this email.
The Exception is always the following:
Exception in thread "main" java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Buffer.java:498)
at java.nio.HeapByteBuffer.getLong(HeapByteBuffer.java:406)
at org.mariadb.jdbc.internal.common.packet.buffer.Reader.readLong(Reader.java:111)
at org.mariadb.jdbc.internal.common.packet.buffer.Reader.getLengthEncodedBinary(Reader.java:173)
at org.mariadb.jdbc.internal.common.packet.buffer.Reader.skipLengthEncodedBytes(Reader.java:140)
at org.mariadb.jdbc.internal.mysql.MySQLColumnInformation.<init>(MySQLColumnInformation.java:118)
at org.mariadb.jdbc.internal.mysql.MySQLProtocol.prepare(MySQLProtocol.java:510)
at org.mariadb.jdbc.MySQLServerSidePreparedStatement.prepare(MySQLServerSidePreparedStatement.java:33)
at org.mariadb.jdbc.MySQLServerSidePreparedStatement.<init>(MySQLServerSidePreparedStatement.java:45)
at org.mariadb.jdbc.MySQLPreparedStatement.getMetaData(MySQLPreparedStatement.java:330)
at TestSQL.main(TestSQL.java:21)
Test:
import java.sql.*;
public class TestSQL {
public static void main(String[] args) throws Exception
{ Class.forName("org.mariadb.jdbc.Driver"); String dbUrl = "jdbc:mysql://harley:3306/pm"; Connection con = DriverManager.getConnection(dbUrl, "pm", "pm"); System.out.println("Connected to " + dbUrl); String queryOk = "SELECT * FROM PMV_EP_QOS_CALLS WHERE IPADDR = '1.0.10.188'"; String queryFail = "SELECT * FROM PMV_EP_QOS_CALLS WHERE IPADDR = ?"; PreparedStatement prepStmt1 = con.prepareStatement(queryOk); ResultSetMetaData md1 = prepStmt1.getMetaData(); System.out.println("Got ResultSetMetaData for: " + queryOk); PreparedStatement prepStmt2 = con.prepareStatement(queryFail); prepStmt2.setString(1, "1.0.10.188"); ResultSetMetaData md2 = prepStmt2.getMetaData(); // getMetaData() fails if the query contains at least one '?' con.close(); }