Author |
Message
|
nab054371 |
Posted: Fri Oct 05, 2007 7:36 am Post subject: ExceptionList in JCN - WBIMB 6.0 |
|
|
Disciple
Joined: 15 Nov 2006 Posts: 173
|
Here's what my code snippet looks like:
try{
sqlExecState = createSQLStatement("TESTDB",SQLstatement);
sqlExecstate.setThrowExceptionOnDatabaseError(true);
}
catch{MbException e){
//Exception handling logic
}
It looks like if I were to run into MbDatabaseException(DB2 native error),the java stack from exception list does not include native DB SQL error.
However if I change the sqlExecstate.setThrowExceptionOnDatabaseError(true) to
sqlExecstate.setThrowExceptionOnDatabaseError(false) and then check for sql errors(see below), it looks like I am able to capture native DB SQL error text!
try{
sqlExecState = createSQLStatement("TESTDB",SQLstatement);
sqlExecstate.setThrowExceptionOnDatabaseError(false);
int sqlState = sqlExecState.getSQLCode();
String sqlError = sqlExecState.getSQLErrorText();
}
catch{MbException e){
//Exception handling logic
}
I was wondering if there would be a way to capture such native DB SQL errors even with
sqlExecstate.setThrowExceptionOnDatabaseError(true) option? |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 05, 2007 1:47 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
ThrowExceptionsOnDatabaseError(true) will create ESQL Exceptions.
I won't go so far as to say that it's impossible to catch ESQL exceptions from a JavaCompute node.
I will merely limit myself to calling it "likely very difficult". _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
nab054371 |
Posted: Fri Oct 05, 2007 2:08 pm Post subject: |
|
|
Disciple
Joined: 15 Nov 2006 Posts: 173
|
Hi Jeff,
I am reffering to Native DB2 SQL exceptions not ESQL exceptions!
thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Oct 05, 2007 2:52 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
nab054371 wrote: |
Hi Jeff,
I am reffering to Native DB2 SQL exceptions not ESQL exceptions!
thanks |
Well depending on what you set up the SQL exception will stop the ESQL from executing and raise an ESQL exception...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
nab054371 |
Posted: Fri Oct 05, 2007 2:57 pm Post subject: |
|
|
Disciple
Joined: 15 Nov 2006 Posts: 173
|
ok,help me understand this-
I am using a JCN and making a select call to DB.Why would it generate ESQL exception?
Maybe I am seeing this wrong,but looks like it generates a bunch of exceptions the last one being CHILD SQL EXCEPTION.But nothing that refers to specific SQL error code in DB2.. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 05, 2007 4:29 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It is my guess/belief, without having seen the source code, that MbSQLStatement is actually handled by the ESQL/C++ Runtime.
So any exceptions it catches and regenerates... will be thrown by the ESQL/C++ Runtime... which will be "likely very difficult" to catch from the Java runtime.
Unless you tell it not to specifically catch/regenerate exceptions.. in which case as you have shown they will be thrown to the JNI/MbJava interface and thus passed into the Java Runtime. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Oct 06, 2007 3:49 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
As you are using a JCN have you tried
Code: |
catch (SQLException sqle) {
some code }
catch (MbException mbe) {
some code}
catch (Exception ge) {
some code}
|
?
and which one did get triggered?
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
nab054371 |
Posted: Thu Oct 11, 2007 7:17 am Post subject: |
|
|
Disciple
Joined: 15 Nov 2006 Posts: 173
|
I am not sure what u mean by SQLException?There is no just thing as SQL exception thrown by MB JCN.It throws MQDatabaseException, a subclass of MQException.. |
|
Back to top |
|
 |
|