Getting MySQLNonTransientConnectionException errors? Then Your MySQL Server Might Be Angry At You!

Today I experienced one of those errors that are not related to the actual stuff that you are working on, but because of it you can't work on anything else. The error I was getting was:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
Could not create connection to database server.
Attempted reconnect 3 times. Giving up.

This started happening while I was testing the DSN creation feature on my employer's website. You know the drill, trying different things, run again, put the wrong settings, run again, put the right settings, run again, and so on; until at one point I started getting the above error.

No problem, I thought, lets restart Tomcat/ColdFusion.... Nope, same error... Let's check with the other devs to see if they have the same problem... Nope, everyone is fine.... Let's manually kill the connections from my host... Nope, same error... Let's drop the database and create it again.... Nope, same error... Let's check the number of connections on the MySQL server.... Nope, they are fine...

The only thing I couldn't do or even try was restarting the MySQL server since it is shared by other users and applications. It was "very" frustrating.

So after a couple of hours of trying different things, I fired up a terminal and tried this:

$ mysql -h <the_host_name> -u <the_user> -p

ERROR 1129 (HY000): Host '<my_host>' is blocked because of many connection errors;
unblock with 'mysqladmin flush-hosts'

Lo and behold, finally some light into the issue! The MySQL server was actually blocking my host from connecting to it. I imagine that this was because of the repeated errors while toying with the create dsn functionality. Anyway, after logging into the server from another host and running that command (mysqladmin flush-hosts) I was able to connect again with no problems.

So there you have, if you see that error, it might be that your MySQL server is not liking you at the moment :)

BugLogHQ 1.3 - Beta Available

I've been working this weekend on an update to BugLogHQ, mostly to fix several issues with database access.

Here is the beta release for BugLogHQ 1.3. Download, unzip, try it out, and let me know any bugs you find.

The changes for this release are pretty much all internal to the functioning of BugLog; basically I re-did the way the application interacts with the back end data storages; also added some caching functionality that will improve the performance of the listener and finally made some changes to the main BugLogHQ application (yes, the one with the pretty charts :) ) to improve the performance especially when you have already a lot of bugs.

Enjoy!

Using Polymorphism and Inheritance to Build a Switchable Data Access Layer

One thing I don't like when starting on a new application is having to go through the process of setting up and configuring the database before I can get anything even running at all. So, for a couple of projects I'm working on I thought about reading and writing data to plain and simple XML files and then later replace that section of the code with a proper database access layer.

However the idea of just throwing away a large chunk of the application didn't sound very appealing, so after some thinking, I started playing with the idea of abstracting the actual storage medium from the application logic. Something that would let me change from XML files to database tables without having to change (or throw away) any application code. This, of course would involve some sort Data Access Objects, and also somewhere along the way would incorporate some sort of shape shifting object that would know how to either read/write files or do insert/select/deletes.

Well, after some more playing, thinking and tinkering I came up with a way to address the issue at hand; and in the eventual case that there is someone else out there with a mind as twisted as mine that would actually consider making something like this, I share my solution here.

[More]

BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner