OracleConnection.close () does not close the connection in my session browser

I am starting a test connection, I expect to see a transparent session browser, but at the end of the program I see more than 6 sessions in the 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 !!

+6
source share
2 answers

You must clear the pool:

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

Probably the reason is pooling. From MSDN:

OracleConnection.Close Method

The Close method cancels any pending transactions. It then issues a connection to the connection pool or closes the connection if the connection pool is disconnected.

So, your connection instance will be deleted in C #, but the connection can remain open in the pool, so that a new instance of the open connection can be quickly provided with the next request.

+3
source

All Articles