How to determine if the error was a deadlock? The following transaction has been selected as a victim of a deadlock:

public void side2() throws SQLException, InterruptedException {
    TestConnectionPool connectionPool = new TestConnectionPool();
    try(Connection connection = connectionPool.get()){
        connection.setAutoCommit(false);
        try {
            PreparedStatement update1 = connection.prepareStatement("update t2 set j=j-1");
            update1.execute();
            Thread.sleep(3000L);
            PreparedStatement update2 = connection.prepareStatement("update t1 set j=j-1");
            update2.execute();
            connection.commit();
        }catch (SQLException ex){
            System.out.println("ex.getErrorCode()=" + ex.getErrorCode());
            System.out.println("ex.getSQLState()=" + ex.getSQLState());
            connection.rollback();
        }
    }
}


Its output is as follows:

            /*
     ex.getErrorCode()=60
     ex.getSQLState()=61000
             */


What should I use to determine whether the error is a deadlock: error code, SQL State, or both?
I guess the ex.getErroCode() has returned ORA-00060: deadlock detected while waiting for resource which is deadlock error. Add ORA in front of the returned error code then search online or use Oracle supplied tool oerr as demonstrated below to determine the error details.


  An error code. This is an integer value identifying the error that caused the SQLException instance to be thrown. Its value and meaning are implementation-specific and might be the actual error code returned by the underlying data source. Retrieve the error by calling the method SQLException.getErrorCode.More...





  [oracle@orcl trace]$ oerr ora 60
  
  00060, 00000, "deadlock detected while waiting for resource"
  
  Cause:  Transactions deadlocked one another while waiting for resources.
  
  Action: Look at the trace file to see the transactions and resources
           involved. Retry if necessary.