Description:
The problem occurs when using the connector/j libraries version 3.1.6 or 3.2.0-alpha
but version 3.0.14 works fine.
Environment:
client (Servlets) deployed on Apache Tomcat version 5.0.27 running on Windows XP profesional
mysql version 4.1.10-nt-max running on Windows XP (on a different computer)
The table in question (link) is using InnoDB
The problem:
Creating a prepared statement with a ? as the last character in the limit clause causes an exception (Syntax error in the SQL statement)
The line (LinkHandler.java:185) that causes the problem (con is the connection to the database):
PreparedStatement ps = con.prepareStatement("SELECT linkid FROM link LIMIT 0 , ?");
The stacktrace:
java.sql.SQLException: 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 '?' at line 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
at com.mysql.jdbc.ServerPreparedStatement.serverPrepare(ServerPreparedStatement.java:1485)
at com.mysql.jdbc.ServerPreparedStatement.<init>(ServerPreparedStatement.java:151)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1309)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1281)
at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:185)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:278)
at startpagina.dbhandler.LinkHandler.getTopX(LinkHandler.java:185)
How to repeat:
create a simple table using InnoDB and either a 3.1.x or 3.2.x version of the connector/j library and try to create the prepared statement mentioned above.