Tom Hubbard
Tom Hubbard

Reputation: 16139

Is there a way to reset all ColdFusion connections from the pool?

We use Oracle and ColdFusion 9.

Whenever an Oracle package gets invalidated it causes every ColdFusion connection to fail with an invalid package warning on the next time the connection accesses the particular package.

Is there a programmatic way to invalidate all ColdFusion connections in the pool?

Upvotes: 2

Views: 720

Answers (1)

Leigh
Leigh

Reputation: 28873

A quick and dirty option for a development server is to modify the datasource settings via the admin api. I believe disabling/enabling connection pooling (or just modifying the dsn) automatically closes all connections.

Here is an MS SQL example. The settings for Oracle may differ slightly.

<cfscript>
    // get datasource api
    adminAPI = createObject("component", "cfide.adminapi.administrator");
    adminAPI.login( "cf_admin_password" );
    dsnService = createObject("component","cfide.adminapi.datasource");

    // disable pooling
    // NOTE: change setMSSQL() to setOracle() 
    props = {name="MyDatasourceName", pooling=false, host="127.0.0.1", database="MyDBName"};
    dsnService.setMSSQL(argumentCollection=props);

    sleep(2000);

    // re-enable pooling
    props.pooling = true;
    dsnService.setMSSQL(argumentCollection=props);

    // sanity check
    finalSettings = dsnService.getDatasources()[props.name];
    if (finalSettings.pooling) {
        WriteDump("SUCCESS");
    } else {
        WriteDump("ERROR: Pooling was not re-enabled");
    }
</cfscript>

Upvotes: 2

Related Questions