I've just spent a while figuring out a painful bug in CF and am posting here so that I can reference it from the Adobe bug tracker as I can't explain the problem in 2000 characters.
Summary of Problem
CF 7.0.2 Cumulative Hotfix 2 and 3 breaks the use of Multiple SQL statements with MySQL connectorJ connector.
This is a regression as it works perfectly in CF 7.0.2 and CF 7.0.2 with Cumulative hotfix 1.
I have tested the following configurations:
- CF7.0.2 MySQL connectorJ 5.0.8 - works
- CF7.0.2 hotfix 1 MySQL connectorJ 5.0.8 - works
- CF7.0.2 hotfix 2 MySQL connectorJ 5.0.8 - broken
- CF7.0.2 hotfix 3 MySQL connectorJ 5.0.8 - broken
- CF7.0.2 MySQL connectorJ 3.1.10 - works
- CF7.0.2 hotfix 1 MySQL connectorJ 3.1.10 - works
- CF7.0.2 hotfix 2 MySQL connectorJ 3.1.10 - broken
- CF7.0.2 hotfix 3 MySQL connectorJ 3.1.10 - broken
Steps to reproduce bug:
1. Set up a CF 7.0.2 Multiserver install with built in webserver
2. Download and install ConnectorJ JDBC driver for MySQL and install as per Adobe Technote http://www.adobe.com/go/6ef0253
3. Create a mysql database named "test" the and create a table with the following script:
CREATE TABLE `tbl_test` (
`id` int(11) AUTO_INCREMENT NOT NULL,
`data` varchar(50) NULL,
PRIMARY KEY(`id`)
)
4. In CF Admin create a DSN named dsn_test with following settings
- JDBC Url: jdbc:mysql://127.0.0.1:3306/test?allowMultiQueries=true
- Driver Class: com.mysql.jdbc.Driver
- Driver name: (leave blank)
- username: (valid user for your db - default: root)
- password: (valid password for your db - default: 'blank')
- Place the following file in the /opt/jrun4/servers/cfusion/cfusion-ear/cfusion-war directory
MySQL driver version:
<cftry>
<cfset oDriver = createObject("java","com.mysql.jdbc.Driver")>
<cfoutput> #oDriver.getMajorVersion()#.#oDriver.getMinorVersion()#</cfoutput>
<cfcatch type="any">
Unknown
</cfcatch>
</cftry>
<cfquery name="qTest" datasource="dsn_test">
INSERT INTO tbl_test (data)
VALUES ('Test String');
SELECT LAST_INSERT_ID() as lastInsertID;
</cfquery>
<cftry>
<cfdump var='#qTest#'>
<cfcatch type="any">
No Query set returned from query.
</cfcatch>
</cftry>
This code should function correctly and return a cfdump of the auto generated primary key as per expected screenshot.
Next apply Coldfusion Cumulative hotfix 2 and restart coldfusion as per Adobe Technote http://www.adobe.com/go/kb400996
Re run the test and no query set will be returned from the driver. The qTest variable does not get set as per the broken screenshot.
Related Resources
Technote re upgrading MySQL JDBC Drivers
http://www.adobe.com/go/6ef0253
CF Updates page http://www.adobe.com/support/coldfusion/downloads_updates.html#mx7
CF 7.0.2 Cumulative hot 3 http://www.adobe.com/go/kb402465
CF 7.0.2 Cumulative hot 2 http://www.adobe.com/go/kb400996
CF 7.0.2 Cumulative hot 1 http://www.adobe.com/go/kb400074
MySQL ConnectorJ http://www.mysql.com/products/connector/j/
MySQL ConnectorJ 3.1.10 Download: http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-3.1.10.tar.gz/from/pick#mirrors