Problem using Oracle OCCI and Signal Handling [message #132568] |
Sun, 14 August 2005 21:10 |
mymot
Messages: 225 Registered: July 2005
|
Senior Member |
|
|
Hi,
Before any OCCI calls are made the program responds to ctl-c, and terminates properly. After the OCCI calls have been made the signal handling seems to disappear and the program no longer responds to ctl-c. The version of OCCI that is being used it 9.2.0.6.0. Connection to the db works & data is printed to the screen.
The code being run is:
#include <occi.h>
#include <iostream.h>
#include <string.h>
#include <signal.h>
using namespace std;
static void signal_handle(int sig_num);
static void sigpipe_handle(int sig_num);
int running = 1;
static void sigpipe_handle(int sig_num)
{
/* Re-set SIGTERM signal handler. */
::signal(SIGPIPE, sigpipe_handle);
// dont do anything. sockets sort them selves out by return values.
}
static void signal_handle(int sig_num)
{
/* Re-set SIGTERM signal handler. */
::signal(SIGINT, signal_handle);
::signal(SIGTERM, signal_handle);
// out of context - get the instance.
//GS_Configuration::getInstance()->setGSShutdown(true);
running=0;
}
// MAIN EXECUTION
int main(int args, char *argv[])
{
oracle::occi::Environment *env;
oracle::occi::Connection *conn;
oracle::occi::Statement *stmt;
oracle::occi::ResultSet *rset;
::signal(SIGINT, signal_handle);
::signal(SIGTERM, signal_handle);
::signal(SIGPIPE, sigpipe_handle);
cout << "Attempting to connect to server" << endl;
try
{
env = oracle::occi::Environment::createEnvironment (oracle::occi::Environment::DEFAULT);
conn = env->createConnection ("usr", "pwd", "db");
cout << "Connection Estabolished OK" << endl;
string sqlStmt = "SELECT STATES FROM COUNTRY";
stmt = conn->createStatement (sqlStmt);
rset = stmt->executeQuery ();
while (rset->next ())
{
cout << "Result!" << rset->getString(1) << endl;
}
stmt->closeResultSet (rset);
conn->terminateStatement (stmt);
}
catch(oracle::occi::SQLException ex)
{
cout<<"Exception thrown for displayAllRows"<<endl;
cout<<"Error number: "<< ex.getErrorCode() << endl;
cout<<ex.getMessage() << endl;
cout << "We have a problem!" << endl;
}
while(running==1)
{
cout << "simulate working after OCCI query" << endl;
}
} // end main
Any suggestions!!
Thanks
|
|
|
|