.netwindowsoracleodp.net

How to test if an OracleConnection is "not Connected to Oracle"?


We are writing a Service that waits on an Oracle Queue via ODP.Net. We are trying to best handle session or network interruptions.

The wait on the queue will return "EOF on communication channel" if I kill the session, from that point all attempts to use the connection give "Not connected to Oracle" exceptions.

Is there a simple way to test if the connection would give "Not connected to Oracle" if it were used? NOTE: (theConnection.State == ConnectionState.Open) is coming back true even though the connection is not connected to Oracle.

Thanks in advance -

sh-


Solution

  • Decided to make my last comment the answer. If someone has an better alternative I would love to hear it.

    I performed these tests to determine the least expensive 'ping'-query:

    1. select * from dual using ExecuteScalar
    2. select * from dual using ExecuteNonQuery
    3. select sysdate from dual using ExecuteScalar
    4. select sysdate from dual using ExecuteNonQuery

    I did 1000 iterations of each and ran them 4 times.

    RESULT: they are all about the same. On my system about 8.5 iterations per sec (which sucks). I expect the database performance is by far the most determining factor so using ExecuteScalar or ExecuteNonQuery (or even ExecuteReader) will probably not affect the performance.

    I also tried "select 0 from dual" with the same results.