code: public static boolean isSqlStateDuplicateValueInUniqueIndex(SQLException se) {
          String sqlState = se.getSQLState();
          return sqlState != null && (sqlState.equals("23505") || se.getMessage().contains("duplicate value in unique index"));
      }
docs: Determines if the SQL exception a duplicate value in unique index.
  
  @param se the exception
  @return true if it is a code 23505, otherwise false