Skip to main content
Inspiring
January 30, 2024
Answered

Database Issue - CFCATCH/CFTRY

  • January 30, 2024
  • 2 replies
  • 359 views

I have an application that periodically throws this error

Error Executing Database Query.Communications link failure The last packet successfully received from the server was 878,178 milliseconds ago. The last packet sent successfully to the server was 18,954 milliseconds ago. The specific sequence of files included or processed is:  .......

I think this is because the DB is on a different server.
Is there any suggestions on how to fix this issue. 

The error occurs periodically.

If the DB issue cant be fixed could I use cfcatch.cftry to keep trying until the connection doesnt fail?

Maybe like this

 

<cftry>
Problem DB query goes here
    <cfcatch ...>
        <cftry>
          TRY DB query AGAIN?
            <cfcatch ...>
       TRY DB query AGAIN?
            </cfcatch
        </cftry>
    </cfcatch>
</cftry>

 

    This topic has been closed for replies.
    Correct answer BKBK

    I agree with @sdsinc_pmascari that you should look for a database solution, rather than a CFML solution. With regard to this, I have a suggestion.

     

    1. Open the ColdFusion Administrator. Go to the datasource page.
    2. Click to edit the datasource for which you are having the issue. Click on the button "Show Advanced Settings".
    3. Have a look at the "Maintain Connections" setting. Is its checkbox unchecked
    4.  If it is,, then that is probably the cause of the issue. Check the checkbox, and press the Submit button. 
    5.  If the checkbox is checked, then that is probably not the cause of the issue. The cause might be an outdated database driver. What is your database's driver version?
      Ensure that you have an up-to-date driver. Drivers usually have capabilities for connection-pooling, which help prevent communication failures.  

    2 replies

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    March 22, 2024

    I agree with @sdsinc_pmascari that you should look for a database solution, rather than a CFML solution. With regard to this, I have a suggestion.

     

    1. Open the ColdFusion Administrator. Go to the datasource page.
    2. Click to edit the datasource for which you are having the issue. Click on the button "Show Advanced Settings".
    3. Have a look at the "Maintain Connections" setting. Is its checkbox unchecked
    4.  If it is,, then that is probably the cause of the issue. Check the checkbox, and press the Submit button. 
    5.  If the checkbox is checked, then that is probably not the cause of the issue. The cause might be an outdated database driver. What is your database's driver version?
      Ensure that you have an up-to-date driver. Drivers usually have capabilities for connection-pooling, which help prevent communication failures.  
    Legend
    January 31, 2024

    Most of the time when I've seen that error it was due to the DB server or service being restarted.  I would focus on the DB issue.

     

    The try-catch proposal you mentioned may work but is just a band-aid.  Best solve the actual problem.