tags:

views:

117

answers:

2

How to prevent the connection to the oracle server being gets lost if it is kept for some ideal time

A: 

If you use the newest JDBC spec 4.0 there is a isValid() method available for a connection that allows you to check if the connection is usable, if not then get a new (reconnect) connection and execute your SQL.

Gandalf
Your answer is appreciable but I am not using JDBC. I want to do it in C
Sachin Chourasiya
A: 

One possible way that I knew to save the database connection from being getting lost is to send a dummy query after the threshhold time, By Threash hold I mean the time after which the connection to the database is expected to become idle or get lost.

Some thing like

Ping_time_to_DB=60

if(Current_time - Last_Ping_time > Ping_time_to_DB)
{
     --send a dummy query like 
       select 1 from dual;
}
Sachin Chourasiya