Skip to main content
July 21, 2008
Question

Database locks up

  • July 21, 2008
  • 1 reply
  • 513 views
While developing my website I am having problems where my mysql database seems to lock up and displays errors on every page that request a DB connection. I contacted my hosting company and they said:

As for the database issue you describe, that is a coldfusion issue with holding on to mysql connections for to long and then the mysql server dropping those connections. If possible, you should try to recycle the connection or close and open them as needed.

Has anyone else run into this problem and how do I close the db connection or recycle it?
    This topic has been closed for replies.

    1 reply

    Inspiring
    July 21, 2008
    Can you post the errors?

    I use Oracle with CF, and I've never had this issue, but thinking back to my MySQL/PHP days it seems like I had to re-establish the MySQL link often. Or maybe I just did, I don't know if I had to.
    July 21, 2008
    Error Executing Database Query.
    > [Macromedia][SequeLink JDBC Driver][ODBC Socket][MySQL][ODBC 3.51
    > Driver][mysqld-5.0.45-log]MySQL server has gone away
    >
    > The error occurred in
    > D:\hshome\user\domain\index.cfm:
    > line 18
    >
    > 16 : <cfset thisDate = Day(Now())>
    > 17 :
    > 18 : <cfquery datasource="myds" username="user"
    > password="pass" name="update_date" >
    > 19 : Select * from tblcookie
    > 20 : </cfquery>
    July 21, 2008
    ColdFusion defaults to maintaining an active connection for 20 minutes. It then uses a default interval of 7 minutes to scan thru connections and closing the datasource connections that have been marked for closure. So, by default your connections are open 20 - 27 minutes. Your hosting company is probably closing them before that via the database, a firewall setting or some other mechanism. ColdFusion expects to control its connections. Set the timeout and interval lower than the close time you hosting company uses in the advanced settings dialog of the datasource. Get that time from you hosting company. Alternatively, you can turn off maintain connections but that will negatively impact performance.

    You are using an ODBC connection to MySQL. I would recommend using a JDBC connection. CF8 comes with the Connector/J ver5 jdbc driver. CFMX7 works with it if you have it install it from mySQL.