Bug #117294 Updatable ResultSet fails with 'Parameter index out of range'
Submitted: 27 Jan 9:38 Modified: 27 Jan 12:02
Reporter: Erik van Dongen Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:9.2.0 OS:Any
Assigned to: Mark Matthews CPU Architecture:Any
Tags: Connector J, java, regression

[27 Jan 9:38] Erik van Dongen
Description:
In our codebase (https://github.com/frankframework/frankframework/), we have a piece of code that'll update a result set with a timestamp after reading it. This has been in place and working for over 10 years with different DBMS's. 

After updating the mysql-connector-j driver to 9.2.0, our integration tests fail with the following stacktrace:

Caused by: java.sql.SQLException: Parameter index out of range (4 > number of parameters, which is 2).
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:121)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:81)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:55)
	at com.mysql.cj.jdbc.ClientPreparedStatement.checkBounds(ClientPreparedStatement.java:1482)
	at com.mysql.cj.jdbc.ClientPreparedStatement.getCoreParameterIndex(ClientPreparedStatement.java:1497)
	at com.mysql.cj.jdbc.ClientPreparedStatement.getBytesRepresentation(ClientPreparedStatement.java:1249)
	at com.mysql.cj.jdbc.result.UpdatableResultSet.refreshRow(UpdatableResultSet.java:1083)
	at com.mysql.cj.jdbc.result.UpdatableResultSet.updateRow(UpdatableResultSet.java:1215)

How to repeat:
I have reproduced this with a simple unit test: https://github.com/evandongen/mysql-connector-j-issue

The project uses 9.1.0 and the unit test will succeed. If you update it to 9.2.0 in the pom.xml, it will fail.

Suggested fix:
I'm not sure, but it might have something to do with "Fix for Bug#71143 (Bug#17967091), Calling ResultSet.updateRow should not set all field values in UPDATE"
[27 Jan 11:26] MySQL Verification Team
Hi Mr. Dongen,

Thank you for your bug report.

However, let us inform you how this forum functions. All bug reporters are obliged to provide a fully repeatable test case for any of their reports. A test case should consist of the set of SQL statements and   all the settings, all the Connector/Java code that produced the error(s).

We have not received all these data from you and hence we can not proceed with the further processing of this bug report.

Can't repeat.
[27 Jan 11:55] Erik van Dongen
Hi there, please see the linked github repository with a java project to reproduce this behavior.

You say "We have not received all these data from you and hence we can not proceed with the further processing of this bug report". Can you please tell me what is missing in the github repository instead of simply closing the issue? I've tried to prepare this issue as good as I could.
[27 Jan 11:59] MySQL Verification Team
Hi M.r Dongen,

We can not analyse your entire code ......

We need just the shortest possible test case that we can run and reproduce the bug that you report.

Hence, we need just a test case based ONLY on what you describe as " we have a piece of code that'll update a result set with a timestamp after reading it".

Also, follow our requests regarding all SQL statements needed for that code excerpt to work.

Can't repeat.
[27 Jan 12:02] MySQL Verification Team
Hello Erik van Dongen,

Thank you for the report and feedback.
Verified  as described.

regards,
Umesh
[27 Jan 16:14] Niels Meijer
Pfff quite hilarious how you guys respond to bug reports.

Time and effort is put into reproducing this in a 15 line test and you guys first shoot it down as 'no test case provided' and then 'test is too large'.

Also please install a spell checker or use a machine to type for you.