/**
  * Extract the name of the violated constraint from the given SQLException.
  *
  * @param sqle The exception that was the result of the constraint violation.
  * @return The extracted constraint name.
  */
 public String extractConstraintName(SQLException sqle) {
   final int errorCode = JdbcExceptionHelper.extractErrorCode(sqle);
   if (errorCode == 1 || errorCode == 2291 || errorCode == 2292) {
     return extractUsingTemplate("(", ")", sqle.getMessage());
   } else if (errorCode == 1400) {
     // simple nullability constraint
     return null;
   } else {
     return null;
   }
 }
Esempio n. 2
0
        public String extractConstraintName(SQLException sqle) {
          String constraintName = null;

          int errorCode = JdbcExceptionHelper.extractErrorCode(sqle);

          if (errorCode == -8) {
            constraintName = extractUsingTemplate("; ", " table: ", sqle.getMessage());
          } else if (errorCode == -9) {
            constraintName = extractUsingTemplate("; ", " table: ", sqle.getMessage());
          } else if (errorCode == -104) {
            constraintName = extractUsingTemplate("; ", " table: ", sqle.getMessage());
          } else if (errorCode == -177) {
            constraintName = extractUsingTemplate("; ", " table: ", sqle.getMessage());
          }
          return constraintName;
        }
Esempio n. 3
0
        /**
         * Extract the name of the violated constraint from the given SQLException.
         *
         * @param sqle The exception that was the result of the constraint violation.
         * @return The extracted constraint name.
         */
        public String extractConstraintName(SQLException sqle) {
          String constraintName = null;

          int errorCode = JdbcExceptionHelper.extractErrorCode(sqle);

          if (errorCode == -8) {
            constraintName =
                extractUsingTemplate(
                    "Integrity constraint violation ", " table:", sqle.getMessage());
          } else if (errorCode == -9) {
            constraintName =
                extractUsingTemplate(
                    "Violation of unique index: ", " in statement [", sqle.getMessage());
          } else if (errorCode == -104) {
            constraintName =
                extractUsingTemplate(
                    "Unique constraint violation: ", " in statement [", sqle.getMessage());
          } else if (errorCode == -177) {
            constraintName =
                extractUsingTemplate(
                    "Integrity constraint violation - no parent ", " table:", sqle.getMessage());
          }
          return constraintName;
        }