Bug #7686 ResultSet.updateRow() fails because of failed refresh SQL
Submitted: 5 Jan 2005 13:32 Modified: 14 Feb 2005 17:03
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.0.16ga OS:Windows (winxp)
Assigned to: Eric Herman CPU Architecture:Any

[5 Jan 2005 13:32] [ name withheld ]
Description:
When I try to make an update on an updatable resultset, the update itself works.
But the refreshRow() performed afterwards fails --> UpdatableResultSet.java:1569

It seems to me that the cause is related to a DATETIME column which is part of the PK used to perform the refresh.
The raw PreparedStatement looks alright to me:
SELECT `INT_SENT_RESPONSES`,`DAT_START`,`ID_APPLICATION`,`ID_USER` FROM `mgp`.`TBL_SESSION_LOGGING` WHERE `DAT_START`=? AND `ID_APPLICATION`=? AND `ID_USER`=?

but after the keys have been inserted in lines 665 - 701, the select statement looks just like this:
SELECT `INT_SENT_RESPONSES`,`DAT_START`,`ID_APPLICATION`,`ID_USER` FROM `mgp`.`TBL_SESSION_LOGGING` WHERE `DAT_START`='_binary'2005-01-05 13:59:20'' AND `ID_APPLICATION`='demo' AND `ID_USER`='TestUser'

where it's clear that the part >`DAT_START`='_binary'2005-01-05 13:59:20''< causes the problem.

This seems to happen in PreparedStatement.setBytesNoEscape() (line 1687), where the _binary'2005-01-05 13:59:20' gets sourrounded by two '.
obviously, the sourrounding '' has to be omitted here!

How to repeat:
just update a row with a DATETIME column included in the PK, I guess

Suggested fix:
omitt the '' for such cases...
[7 Jan 2005 2:17] Eric Herman
I was able to re-create the bug on the Connector/J 3.0 branch as well as similar in 3.1 and 3.2 
branches. Mark had the insight as to how to fix the bug (strip off the starting "_binary'" and 
ending "'") and we've added the change to each of those branches.