I use JDBC against oracle with con.setAutoCommit(false).
My transaction perform several updates so concurrent execution of my transaction may cause java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource.
Normally, I think I should do a rollback and retry the transaction that failed due to deadlock. My question is how my java code identify the SQLException is caused by deadlock? Is it by parsing the String returned from exception.getMessage() to see if it contains ORA-00060? Would there be a better approach?
You could take a look at SQLException's getErrorCode() method since it returns an int, from SQLException API: getErrorCode public int getErrorCode() Retrieves the vendor-specific exception code for this SQLException object.