Feb 22
I have been having a problem with a CFMX6.1 server that just would not maintain connections to MySQL DSN's, if you added the DB username/password into the DSN, it would work for a while, but would eventually timeout and give the error below.
Specifying the username/password in your code just did not work at all, always causing the below error.
Cannot connect to MySQL server on servername:3306. Is there a MySQL server
running on the machine/port you are trying to connect to?
(java.security.AccessControlException)
It turns out this is caused if you have security sandboxes enabled. Even if you have NOTHING specified in your server/ports section which whould thus mean no restrictions, ColdFusion still disallows access to the MySQL Server.
In my case I have a default sandbox on the folder where all the web sites are located. So I explicity allowed the Server/Port of the MySQL server here, and it has solved the problem.
The Explanation as to the reason for this behaviour goes something like this:-
When you create a DSN via the CFADMIN with a username/password, it creates a pooled connection which works because the CFADMIN has access to the Server/Port of MySQL. Any code that now uses that DSN uses the already verified pooled connection. This connection will however be closed after 20 minutes of inactivity.
If you pass the username/password in your code, a new connection is created, which does not have access to the Server/Port because of the sandbox, thus it fails to connect.
This behaviour does not however seem to be consistent, as I have other CFMX servers using sandboxing where MySQL DSN's work fine without neeidng to explicity specify the Server/Port of the MySQL Server in any sandbox.
You would also expect the same problem to affect SQL Server DSN's, but it doesn't.
On top of these problems, I also couldn't get the alternate connector/J MySQL driver to work on this server. After solving the above problem, I then started getting the below error. This was using the 3.2.0-alpha driver, which was the only one that I could previously get to work on other servers. But this was supposedly causing conflicts with log4j libraries in the newer 3.1.8 jar and greater and the CFMX own log4j interface. So I changed to the 3.0.16ga driver, which now appears to be working.
Connection verification failed for data source: jf1[]java.sql.SQLException:
Unable to instantiate logger class 'com.mysql.jdbc.log.Log4JLogger', exception
in constructor?The root cause was that: java.sql.SQLException: Unable to
instantiate logger class 'com.mysql.jdbc.log.Log4JLogger', exception in
constructor?
Thanks to Nick Watson @ Adobe for his help in resolving this issue.
Recent Comments