user1012506 user1012506 - 20 days ago 8
C# Question

oracleConnection.close() dont close the connection in my session browser

I make run of test connection, I expect to see clear session browser,
but at the end of the program, I see more then 6 sessions in my session browser

This is the code:

private void testConnection()
{
string connectionString = "data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1111)(PORT=1699))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = abcd)));Min Pool Size=10; Connection Lifetime=120;";

OracleConnection oraConn = new OracleConnection(connectionString);

try
{
oraConn.Open();
}

catch (Exception e)
{
}

finally
{
oraConn.Dispose();
oraConn.Close();
}

}


plz, help me!!

Answer

You should clear the pool:

 finally
    {
        oraConn.Dispose();
        oraConn.Close();
        OracleConnection.ClearPool(oraConn);
    }