当前位置: 代码迷 >> Oracle技术 >> oracle 错误获取有关问题
  详细解决方案

oracle 错误获取有关问题

热度:72   发布时间:2016-04-24 08:36:59.0
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的错误信息就好了
  相关解决方案