Coldfusion 9 MySQL communications link failure
I've just installed Coldfusion 9, and everything is now working fine and it's connected to my MySQL databse via the Coldfusion Administrator as a datasrouce, but I get this error occuring infrequently, maybe 5 - 10 times a day. I don't know how to recreate it, and if you get it and refresh the page it goes away.
Error Executing Database Query. Communications link failure Last packet sent to the server was 0 ms ago
The error is being caught by coldfusion as it's displaying a user friendly message and emailing me the problem.
Almost all of the time the pages load and work fine, and this problem has only happened since going from CFMX7 to CF9, both using MySQL.
The MySQL version I am using is "5.0.77"
I've tried localhost and 127.0.0.1 as the host in the datasource, it makes no difference.
Does anyone have any idea what this is and how to fix it? I've seen some similar posts for Java but I don't see how to translate the fix across into Coldfusion? And could it be a MySQL or Apache problem anyway?
EDIT: I UNCHECKED maintain connections at 11am yesterday (11th), and not had the error since. Usually I was getting 3 - 10 a day, so this seems hopeful. I'll wait until tomorrow before confirming it is fixed. I'm using the MySQL 4/5 driver on 5.0.77
This issue was discussed on the Adobe forums. It appears that a suitable workaround is to enable a Validation Query in the ColdFusion datasource definition such as " Select 1
" (without quotes). ColdFusion will test every connection by running that simple query before letting the page request use that db connection. This will guarantee that every db connection is good before use in the application.
More details available at: http://forums.adobe.com/message/3396302#3396302
Apache wouldn't be your problem unless you are talking about Apache Tomcat as your servlet engine for ColdFusion. Apache HTTPD wouldn't be able to cause that.
It does seem like this is a bug in between the JDBC Connector and MySQL. Could you tell me what version of mysql you are on?
Adding the Validation Query to the datasource fixed the same problem for me as per the solution given by Steven Erat.
I'd simply add that you need to make sure you add the "SELECT 1" query AND check the "Enable connection validation" checkbox just above the query.
I missed checking the box on a few datasources and the problem snuck back in later... (grin)
链接地址: http://www.djcxy.com/p/31234.html