I have found in certain scenarios, you may need to use the coldfusion admin API to verify your datasources. If you are maintaining datasource connections and you have a clustered SQL environment, You may find that when one of your active nodes fails to the second node, CF has no idea what just happened. It tries to contact the SQL server because that is the cached connection it has and finds out it is not available. You will then begin to see “Socket reset by peer”, meaning that client connections to SQL have been dropped. A way to mitigate that is to either put “alternateServers=” string in your connection string or use the following script below to reverify all your datasources so that CF is forced to pick up the new location.

Ex.


<cfscript>
    adminObj = createObject("component","cfide.adminapi.administrator");
    createObject("component","cfide.adminapi.administrator").login('testpassword);
    myObj = createObject("component","cfide.adminapi.datasource");
    myObj2 =  createObject("java","coldfusion.server.ServiceFactory");
    myObj2 = myObj2.datasourceservice.getdatasources() ;
</cfscript>

<cfloop collection="#myObj2#" item="ds">
  <cfset verifyDs = myObj.verifyDSN(ds)>
  <cfoutput>
     #ds# / Verified - #verifyDS<br>
  </cfoutput>
</cfloop>

Advertisements