Berryman - 2007-11-16

Using the Universal Driver for DB2 (com.ibm.db2.jcc.DB2Driver) db2 does not send back very user friendly error messages with just the getMessage() routine.  With getMessage() you only get the error codes.  It would be nice if the we could also get the user friendly version of the error messages the following code will retrieve these messages as well but am I unsure of where this code could be added. 

try
{
  stmt.executeUpdate("CREATE TABLE t ( a INT )");
}
catch (SQLException e)
{
  
  //print the error message with codes
  System.out.println(e.getMessage());
 
  //print the error message with user friendly explination
  if (e instanceof DB2Diagnosable)
  {
    DB2Diagnosable db2e = (DB2Diagnosable)e;
    DB2Sqlca sqlca = db2e.getSqlca();
    System.out.println("");
    System.out.println(sqlca.getMessage());
  }
}