Tuesday, November 16, 2010

ColdFusion 9: ByteArray error

If you've upgraded to ColdFusion 9 with MySQL, be prepared to get a "ByteArray objects cannot be converted to strings." error. This error occurs because the JDBC driver for MySQL included with the ColdFusion 9 install converts TinyInt values to a Byte Array if they're used in a function or a CASE WHEN. You will not get this error if you're simply including a TinyInt column in a SELECT statement, but you will get it if you're using it inside a function or a CASE WHEN.

One solution is to encapsulate your function in a CONVERT([function] USING latin1), but you will have to do it in every query where this condition occurs.

Another solution is to revert to an earlier driver. ColdFusion 9 install includes mysql-connector-java-commercial-5.1.7-bin.jar. You can try downloading the latest driver from here, however, version 5.1.13 still had this bug. If you're still having a problem after downloading the newest driver, revert to the version which was included with ColdFusion 8, mysql-connector-java-commercial-5.0.5-bin.jar.

2 comments: