您的位置:首页 > 产品设计 > UI/UE

关于mybatis查询出错,异常情况下返回值的问题

2018-03-01 16:01 555 查看
public class MybatisExceptionTest {

public static void main(String[] args) {
try {
System.out.println(testListReturn());
} catch (Exception e) {
e.printStackTrace();
System.out.println("此处是dao层异常,自己需要判断return的值");
}

}

private static List<String> testListReturn() throws Exception {
List<String> list;
try {
List re = test();
list = re;
} catch (Exception ex) {
throw new Exception(ex);
}
return list;//此处是sqlSession中selectList的返回
}

private static List<String> test() throws Exception {
int i = 0;
if (i != 1) {
throw new Exception("test mybatis exception");
}
return new ArrayList<>();
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息