Rithanya Laxmi wrote:Thanks. The exception.getMessage() returns only "org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update" and not
ORA-00001. Similarly the exception.getCause() returns only "ConstraintViolationException". Hence how we can get the respective Oracle error code & message? Please clarify.
That's right, getMessage() returns what you said. That message does not contain any "ORA-"-parts. So that's 2b from my post. Call getCause() which gives you another Throwable. This one is not null, so start over with No. 1 on THAT throwable - didn't mention this explicitly because it was quite clear to me.
If the stacktrace above is correct, this getMessage() should bring "java.sql.BatchUpdateException: ORA-00001: unique constraint (RRTS.RRTS_CUST_ID_PK) violated".
Do this as long as:
- getCause() does not return null
OR
- getMessage() contains what you're looking for