Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 按错误代码范围显示SQL异常_Java_Oracle_Error Handling - Fatal编程技术网

Java 按错误代码范围显示SQL异常

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

我试图迭代一个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(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.