Reconnect Oracle Database if disconnected

44 Views Asked by At

Environment: Visual Studio C++ 2022, Windows Server 2019 Datacenter, Oracle Database, Oracle Data Access Components (ODAC)

Hi,

I have developed C++ server application which works by 24x7. My application uses Oracle OleDB to connect Oracle database. After connecting to Oracle database, connection object is being cached. Sometime this connection object become invalid and it report error 'Not connected to Oracle'. At that time my program retry to connect Oracle database but it fails.

When I restart application, program connect to Oracle database successfully.

Oracle OleDB function which are being used

  • CDataSource::OpenFromInitializationString is being used to connect oracle database.

  • CDataSource::Close() is being to close connection.

  • CSession::Open() is being used to open session.

  • CSession::Close() is being used to close session.

My requirement is that to restore Oracle connection without restarting program.

Any idea how this issue can be resolved?

Thanks in advance. Regards, Vijay Kumar Singh

1

There are 1 best solutions below

0
ibre5041 On

Nowadays these problems are better addressed by JDBC drivers than OCI ones. But still you can search for:

  • Oracle DCD, dead connection detection
  • Oracle TCP keepalive, various Firewalls cut of DB connection when it is inactive. Search for (ENABLE=BROKEN) in Oracle's connection string
  • Oracle AC, application continuity, in some cases connection loss can be fully transparent to the application. The driver remembers what data were sent to database, it re-connects and re-transmits data to DB, without app even noticing that something has happened.