Home » Developer & Programmer » Precompilers, OCI & OCCI » Problem using Oracle OCCI and Signal Handling
Problem using Oracle OCCI and Signal Handling [message #132568] Sun, 14 August 2005 21:10 Go to next message
Messages: 225
Registered: July 2005
Senior Member

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 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.

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;

env = oracle::occi::Environment::createEnvironment (oracle::occi::Environment::DEFAULT);
conn = env->createConnection ("usr", "pwd", "db");

cout << "Connection Estabolished OK" << endl;

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;


cout << "simulate working after OCCI query" << endl;

} // end main

Any suggestions!!


Re: Problem using Oracle OCCI and Signal Handling [message #138082 is a reply to message #132568] Mon, 19 September 2005 19:35 Go to previous message
Messages: 4
Registered: September 2005
Junior Member
You need to put the calls to ::signal AFTER you've made the connection to the database.

I had the same problem and solved it by placing my signal handler calls after my connection.

Hope that helps.

Previous Topic: loading flat file to oracle tables using c program
Next Topic: Pro *C Fetch Into Host Array
Goto Forum:

Current Time: Fri Sep 18 16:08:45 CDT 2020