469,963 Members | 2,227 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

Proper error messages in com.ibm.db2.jcc.b.SqlException

Hi All
Just wondering if its possible get more descriptive error messages in
to com.ibm.db2.jcc.b.SqlException. getMessge or toString() methods
gives only SQL-error codes like:
SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096

I am using universal driver...

Thanks for any help

Best Regads, Juha

Jan 20 '07 #1
5 19141
JuhaM wrote:
Hi All
Just wondering if its possible get more descriptive error messages in
to com.ibm.db2.jcc.b.SqlException. getMessge or toString() methods
gives only SQL-error codes like:
SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096

I am using universal driver...

Thanks for any help

Best Regads, Juha
Try:

db2 ? sql1218

from DB2 command line (assuming you installed at least DB2 client).
If you are using DB2 Jcc Universal driver in T2 connectivity mode - you have
installed client software.
If you are using DB2 Jcc Universal driver in T4 connectivity mode (pure lava) -
you may not have installed client software. In this case you can install DB2
documentation locally - or use online version available at:

http://publib.boulder.ibm.com/infoce...w/v9/index.jsp

and search (you can also browse Reference->Messages->SQL Messages) for SQL1218.
here is link to this message:

http://publib.boulder.ibm.com/infoce...oc/sql1218.htm
Jan M. Nelken
Jan 20 '07 #2
JuhaM wrote:
Hi All
Just wondering if its possible get more descriptive error messages in
to com.ibm.db2.jcc.b.SqlException. getMessge or toString() methods
gives only SQL-error codes like:
SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096

I am using universal driver...

Thanks for any help

Best Regads, Juha
Try:

db2 ? sql1218

from DB2 command line (assuming you installed at least DB2 client).
If you are using DB2 Jcc Universal driver in T2 connectivity mode - you have
installed client software.
If you are using DB2 Jcc Universal driver in T4 connectivity mode (pure java) -
you may not have installed client software. In this case you can install DB2
documentation locally - or use online version available at:

http://publib.boulder.ibm.com/infoce...w/v9/index.jsp

and search (you can also browse Reference->Messages->SQL Messages) for SQL1218.
here is link to this message:

http://publib.boulder.ibm.com/infoce...oc/sql1218.htm
Jan M. Nelken
Jan 20 '07 #3
Jan Nelken wrote:
JuhaM wrote:
>Hi All
Just wondering if its possible get more descriptive error messages in
to com.ibm.db2.jcc.b.SqlException. getMessge or toString() methods
gives only SQL-error codes like:
SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096

I am using universal driver...
Thanks for any help
DB2 9 for LUW has a stored procedure to retrieve the messagetext for any
SQLCODE in the server language.
Check under "Administrative routines"

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Jan 20 '07 #4
Thanks everyone for the help. Actually I was hoping to get error
messages directly from java, without extra lookup. Perhaps I can use
this sp somehow..
Regards, Juha
Serge Rielau wrote:
Jan Nelken wrote:
JuhaM wrote:
Hi All
Just wondering if its possible get more descriptive error messages in
to com.ibm.db2.jcc.b.SqlException. getMessge or toString() methods
gives only SQL-error codes like:
SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096

I am using universal driver...
Thanks for any help
DB2 9 for LUW has a stored procedure to retrieve the messagetext for any
SQLCODE in the server language.
Check under "Administrative routines"

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Jan 20 '07 #5
JuhaM wrote:
Hi All
Just wondering if its possible get more descriptive error messages in
to com.ibm.db2.jcc.b.SqlException. getMessge or toString() methods
gives only SQL-error codes like:
SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096
You can do this (following the description here:
http://publib.boulder.ibm.com/infoce...d/tjvjcerr.htm

try {
stmt.executeUpdate("CREATE TABLE t ( a INT )");
} catch (SQLException e) {
System.out.println("SQL Exception");
System.out.println("=============");
System.out.println(e.getMessage()); // (1)
System.out.println("");
if (e instanceof DB2Diagnosable) {
DB2Diagnosable db2e = (DB2Diagnosable)e;
DB2Sqlca sqlca = db2e.getSqlca();
System.out.println(sqlca.getMessage()); // (2)
}
}

You will see in step (1) the error message that contains the sqlcode,
sqlstate, and tokens - which you posted above. On step (2) you will
receive the short message for the error. Or do you need the long error
message, which includes Explanation and User Response, i.e. exactly what
this would return:

$ db2 "? sql0601"
Here is an example of the output I got:

$ javac A.java && java A
SQL Exception
=============
DB2 SQL error: SQLCODE: -601, SQLSTATE: 42710, SQLERRMC: STOLZE.T;TABLE

The name of the object to be created is identical to the existing
name "STOLZE.T" of type "TABLE".

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Jan 21 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by FX NICOLAS | last post: by
3 posts views Thread by tshad | last post: by
reply views Thread by =?Utf-8?B?c3RldmVuLnRob21wc29u?= | last post: by
8 posts views Thread by ajos | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.