I have a Oracle procedure, that uses PL/SQL SQLCODE function in EXCEPTION section. Now I need to translate that procedure in Java. I found SQLException.getErrorCode function. Are results of SQLCODE and SQLException.getErrorCode the same? Is there right way to get result of SQLCODE function in Java?
1 Answer
They are equivalent.
SQLException.getErrorCode(): Retrieves the vendor-specific exception code. (see here)
SQLCODE : In an exception handler, the SQLCODE function returns the numeric code of the exception being handled. (see here)
Suppose if you have a query in which you have specified wrong table name. Then you will get 942 instead of ORA-00942, because getErrorCode() returns int.
Retrieves the vendor-specific exception code for this SQLException object.Try it and see.