Reconnect after otl_terminate()
Brought to you by:
skuchin
Hello *
Here is a very simple program trying to reconnect to Oracle DB after connection has been terminated. This program causes a memory access violation in server_attach (see discussion on reconnect).
The original user requirement is to reconnect Oracle after an network switch from LAN to WLAN took place.
Can anybody explain to me, what is wrong here and how to reconnect successfully ?
Thanks
Juergen
using namespace std;
#include <stdio.h>
#include <iostream>
#define OTL_ORA11G_R2 // Compile OTL 4.0/OCI11.2
#include "otlv4.h" // include the OTL 4.0 header file
int main()
{
otl_connect db;
otl_connect::otl_initialize(); // initialize OCI environment
try
{
db.rlogon(<user>/<pwd>@db_alias"); // connect to Oracle
otl_cursor::direct_exec
(
db,
"select <something>",
otl_exception::disabled
);
}
catch(otl_exception& p)
{
std::cout <<"--> EXCEPTION !! \n" << std::endl;
std::cout<<p.msg<<endl; // print out error message
std::cout<<p.stm_text<<endl; // print out SQL that caused the error
std::cout<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from Oracle
otl_connect::otl_terminate();
std::cout <<"--> Initializing OTL again .. \n" << std::endl;
otl_connect db2;
otl_connect::otl_initialize();
try
{
db2.rlogon(<user>/<pwd>@db_alias"); // connect to Oracle
otl_cursor::direct_exec
(
db2,
"select <something>",
otl_exception::disabled
);
}
catch(otl_exception& p2)
{
// intercept OTL exceptions
std::cout <<"--> EXCEPTION after reconnect !! \n" << std::endl;
std::cout<<p2.msg<<endl; // print out error message
std::cout<<p2.stm_text<<endl; // print out SQL that caused the error
std::cout<<p2.var_info<<endl; // print out the variable that caused the error
}
db2.logoff(); // disconnect from Oracle
return 0;