mirror of https://github.com/apache/openjpa.git
changes for OPENJPA-184.Appending DB2Diagnosable information to the exception.No logging done.
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@525572 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6fe50aa433
commit
729c7af474
|
@ -442,4 +442,39 @@ public class DB2Dictionary
|
|||
append(" ").append(rowClause);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
/** Append exception information from SQLCA to the exsisting
|
||||
* exception meassage
|
||||
*/
|
||||
public String appendExtendedExceptionMsg(String msg, SQLException sqle){
|
||||
final String GETSQLCA ="getSqlca";
|
||||
String exceptionMsg = new String();
|
||||
try {
|
||||
Method sqlcaM2 = sqle.getNextException().getClass()
|
||||
.getMethod(GETSQLCA,null);
|
||||
Object sqlca = sqlcaM2.invoke(sqle.getNextException(),
|
||||
new Object[] {});
|
||||
Method getSqlErrpMethd = sqlca.getClass().
|
||||
getMethod("getSqlErrp", null);
|
||||
Method getSqlWarnMethd = sqlca.getClass().
|
||||
getMethod("getSqlWarn", null);
|
||||
Method getSqlErrdMethd = sqlca.getClass().
|
||||
getMethod("getSqlErrd", null);
|
||||
exceptionMsg = exceptionMsg.concat( "SQLCA OUTPUT" +
|
||||
"[Errp=" +getSqlErrpMethd.invoke(sqlca,new Object[]{})
|
||||
+ ", Errd=" + Arrays.toString((int[])
|
||||
(getSqlErrdMethd.invoke(sqlca, new Object[]{}))));
|
||||
String Warn = new String((char[])getSqlWarnMethd.
|
||||
invoke(sqlca, new Object[]{}));
|
||||
if(Warn.trim().length() != 0)
|
||||
exceptionMsg = exceptionMsg.concat(", Warn=" +Warn + "]" );
|
||||
else
|
||||
exceptionMsg = exceptionMsg.concat( "]" );
|
||||
msg = msg.concat(exceptionMsg);
|
||||
return msg;
|
||||
} catch (Throwable t) {
|
||||
return sqle.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2470,7 +2470,14 @@ public class DBDictionary
|
|||
buf.append(getTypeName(type));
|
||||
buf.append(post);
|
||||
}
|
||||
|
||||
|
||||
/** Append any database specific exception message to
|
||||
* the exsisting exception message
|
||||
*/
|
||||
public String appendExtendedExceptionMsg(String msg, SQLException sqle) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
///////////
|
||||
// DDL SQL
|
||||
///////////
|
||||
|
|
|
@ -87,6 +87,7 @@ public class SQLExceptions {
|
|||
Object failed, DBDictionary dict) {
|
||||
if (msg == null)
|
||||
msg = se.getClass().getName();
|
||||
msg = dict.appendExtendedExceptionMsg(msg,se);
|
||||
SQLException[] ses = getSQLExceptions(se);
|
||||
if (dict == null)
|
||||
return new StoreException(msg).setFailedObject(failed).
|
||||
|
|
Loading…
Reference in New Issue