vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 |
| |||
| 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 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 |
| |||
| 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 |
| ||||
| 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 |