I'm trying to iterate through a SQLException Object and to filter the Error Code for each of his index.
public static void showExceptionByErrorCodeRange(SQLException ex, int range_min, int range_max){
String msg = new String();
int error_code = 0;
Iterator<Throwable> itr = ex.iterator();
while(itr.hasNext()){
SQLException e = (SQLException)itr.next();
error_code = e.getErrorCode();
if(error_code >= range_min && error_code <= range_max){
msg += e.getMessage();
}
}
showErrorMsg(msg);
}
This code compile, but it looks like the SQLException has only one index because the while(itr.hasNext()) only loop once and the e.getMessage() returns this:
ORA-20000: The vendor-specific error message i need to select by my function.\n
ORA-06512: at "any_table", line x\n #<-- default SQL error message.
ORA-06512: at line 1\n #<-- default SQL error message.
I'm able to get the e.getErrorCode() to 20000, but when i add the e.getMessage() to my msg i get all the errors in the same string. (ORA-06512)
Is there any way to seperate the errors (ORA-20000 and ORA-06512) from the getMessage() string without using string logic?
Thank you.