Java 按错误代码范围显示SQL异常
我试图迭代一个SQLException对象,并为每个索引过滤错误代码Java 按错误代码范围显示SQL异常,java,oracle,error-handling,Java,Oracle,Error Handling,我试图迭代一个SQLException对象,并为每个索引过滤错误代码 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(it
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);
}
public static void showExceptionByErrorCodeRange(SQLException ex、int range\u min、int range\u max){
String msg=新字符串();
int error_code=0;
迭代器itr=ex.Iterator();
while(itr.hasNext()){
SQLException e=(SQLException)itr.next();
错误代码=e.getErrorCode();
如果(error\u code>=range\u min&&error\u code),这在很大程度上取决于数据库供应商驱动程序的实现。在这种情况下,您将无法执行此操作。您可以尝试这样做,Oracle的驱动程序以这种方式而不是特定于SQLException的方式链接异常。可能重复:可能重复
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.