Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Problem with OCCI, g++ and catching exceptions

Problem with OCCI, g++ and catching exceptions

From: Johannes Lochmann <johannes.lochmann_at_chello.at>
Date: Tue, 30 Apr 2002 14:43:00 GMT
Message-ID: <slrnactevg.sf9.work@linux.local>


Hello,

I have encountered a problem while using OCCI (Oracle C++ Call Interface) I was not able to solve. I hope someone here can give me a hint how I could further track down the issue.

I have a table:

CREATE TABLE t(

	t	VARCHAR(32),
	CONSTRAINT pk_t PRIMARY KEY(t);

);

I have a Class OInterface:

OInterface{
public:

	OInterface();
	~OInterface();

};

OInterface::OInterface(){

	Environment *env = Environment::createEnvironment();
        Connection conn = penv->createConnection("SCOTT", "TIGER");
        Statement statement = conn->createStatement();

	string str = "INSERT INTO t(t) VALUES(:t)";
	
	try {
		statement->setSQL(str);
		statement->setString(1, "Hello");
		
		statement->executeUpdate();
	} catch (SQLException e) {
		cout	<< endl << "Exception thrown: " 
			<< e.what() << endl;
	}	

}

OInterface::~OInterface(){

	conn->terminateStatement(statement);
        env->terminateConnection(conn);
        Environment::terminateEnvironment(env);

}

The sample compiles fine and works fine until I violate the pk_t constraint of the table t.

As I understand the documentation, in this case an SQLException should be thrown which I should be able to catch with the above try{...} catch(...) {...} construction.

The problem is, the program crashes and no Exception can be catched by my code.

I tried the above code with Oracle 9i using g++ 2.95.3 and g++ 3.0.4 everytime with the same result.

Other exception using libraries work just fine, so I think that I am using OCCI somehow wrong, g++ has a bug here or OCCI has a bug.

Has anybody a clue what the problem could be?

Thank you for your time and help

Johannes Lochmann Received on Tue Apr 30 2002 - 09:43:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US