Display string from raise_application_error in java program

為{幸葍}努か 提交于 2019-12-22 01:43:32

问题


I am raising some application errors from PL/SQL procedures. I am setting some messages for instance,

RAISE_APPLICATION_ERROR(-20001, 'message');

Is there any way, I can display 'message' in exception section in catch block of java program from which I called this procedure?


回答1:


If you're doing catch (Exception e), message should be available from e.getMessage().

If you're doing catch (SQLException e) (or whatever the exception type is for your data access package) message should still be available from e.getMessage(). Additionally, the -20001 should come through in e.getErrorCode(). Note that it may come through as the absolute value (20001 as opposed to -20001); you'll have to experiment.




回答2:


I think this post will help you out: Error catching

catch (GenericJdbcException ge) {

IF (se.getErrorCode() == -20001)

If your not using Hibernate you might need to change the error type.



来源:https://stackoverflow.com/questions/16281654/display-string-from-raise-application-error-in-java-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!