Java - find the first cause of an exception

后端 未结 10 1049
渐次进展
渐次进展 2020-12-09 01:50

I need to check if an exception is caused by some database problem. I receive an Exception and check if its cause contains the \"ORA\" string and return that (something like

10条回答
  •  醉酒成梦
    2020-12-09 02:23

    I think that any error that is thrown by oracle will be wrapped in a SQLException (somebody please correct me if wrong). Once you have accessed the SQLException you should be able to call

    getErrorCode() Retrieves the vendor-specific exception code for this SQLException object.

    Let me know if this works as I have never tried it :-)

    Karl

提交回复
热议问题