oracle 异常获取问题
sql语句:
begin
savepoint ps;
merge into 1;
merge into 2;
merge into 3;
merge into 4;
....
commit;
exception
when others then
rollback to ps;
end;
后台:
try {
String strSql =“sql”;
con = DataSource.getDataSource();
ps = con.prepareStatement(strSql);
int result = ps.executeUpdate();
}
catch (Exception e) {
throw e;
}
希望在页面显示捕获的异常,求解。
------解决方案--------------------
在sql里这样写
exception
when others then
begin
rollback to ps;
raise;
end;
end;
里面的RAISE也可以自己定义错误信息,不过一般用ORACLE的错误信息就好了