Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Problem with OCCI, g++ and catching exceptions
Billy O'Connor schrieb im Artikel <m37kmpgr9s.fsf_at_dpscon.com>:
>>
Here is a minimal working code snippet. If you run it once, it works fine and inserts 'Hello' into t.t. Second run aborts the program because of the violated PRIMARY KEY constraint.
You probably have to change user (SCOTT) and pass (TIGER) in the source.
Compiler is g++ 2.95.3. The command is:
g++ -I$ORACLE_HOME/rdbms/demo -I$ORACLE_HOME/plsql/public \ -I$ORACLE_HOME/rdbms/public -I$ORACLE_HOME/network/public \ -L$ORACLE_HOME/lib -locci -lclntsh -o minimal minimal.cc
Using g++ 3.0.4 gives the follwing error:
In file included from $ORACLE_HOME/rdbms/demo/occiData.h:74,
from $ORACLE_HOME/rdbms/demo/occi.h:40, from minimal.cc:18:
for `virtual oracle::occi::SQLException::~SQLException()' /opt/gcc304/include/g++-v3/exception:53: overriding `virtual
std::exception::~exception() throw ()'
I understand, that the destructor from std is beeing overridden, but what is meant by "looser throw specifier"?
If you need more information please tell me, I would be happy to provide it.
Thank you
Johannes Lochmann
Here is the code snippet:
/*
Short sample for bug tracking purpose. The following table must exist
in an oracle database:
CREATE TABLE t(
t VARCHAR(16), CONSTRAINT pk_t PRIMARY KEY(t)
the user specified below must have insert priv to this table and be able to connect with the given password, obviously.
This sample can be built with the following command:
g++ -I$ORACLE_HOME/rdbms/demo -I$ORACLE_HOME/plsql/public \ -I$ORACLE_HOME/rdbms/public -I$ORACLE_HOME/network/public \ -L$ORACLE_HOME/lib -locci -lclntsh -o minimal minimal.cc
Compiler is g++ 2.95.3.
*/
#include <occi.h>
#include <iostream.h>
using namespace oracle::occi;
using namespace std;
const string user = "emsdevel";
const string pass = "emsdevel";
int main(int argc, char** argv){
Environment *env = Environment::createEnvironment(); Connection *conn = env->createConnection(user, pass); Statement *stmt = conn->createStatement(); try { string qs = "INSERT INTO t(t) VALUES('Hello')"; stmt->setSQL(qs); stmt->executeUpdate(); conn->commit(); } catch (SQLException excp) { cout << endl << "Exception catched: " << excp.what() << endl; }