- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.sql.SQLException
-
- java.sql.SQLNonTransientException
-
- java.sql.SQLIntegrityConstraintViolationException
-
- All Implemented Interfaces:
-
Serializable,Iterable<Throwable>
public class SQLIntegrityConstraintViolationException extends SQLNonTransientException
当SQLState类的值为“ 23 ”时,或在供应商指定的条件下,抛出SQLException的子类。 这表示违反完整性约束(外键,主键或唯一键)。请咨询您的驱动程序供应商文档,
异常可能抛出此异常的供应商指定的条件。- 从以下版本开始:
- 1.6
- 另请参见:
- Serialized Form
-
-
构造方法摘要
构造方法 Constructor 描述 SQLIntegrityConstraintViolationException()构造一个SQLIntegrityConstraintViolationException对象。SQLIntegrityConstraintViolationException(String reason)构造一个SQLIntegrityConstraintViolationException与给定的reason。SQLIntegrityConstraintViolationException(String reason, String SQLState)使用给定的reason和SQLState构造一个SQLIntegrityConstraintViolationException对象。SQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode)构造一个SQLIntegrityConstraintViolationException与给定对象reason,SQLState和vendorCode。SQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode, Throwable cause)构造一个SQLIntegrityConstraintViolationException与给定对象reason,SQLState,vendorCode和cause。SQLIntegrityConstraintViolationException(String reason, String SQLState, Throwable cause)构造一个SQLIntegrityConstraintViolationException与给定对象reason,SQLState和cause。SQLIntegrityConstraintViolationException(String reason, Throwable cause)使用给定的reason和cause构造一个SQLIntegrityConstraintViolationException对象。SQLIntegrityConstraintViolationException(Throwable cause)构造一个SQLIntegrityConstraintViolationException对象与给定的cause。
-
方法摘要
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from class java.sql.SQLException
getErrorCode, getNextException, getSQLState, iterator, setNextException
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
构造方法详细信息
-
SQLIntegrityConstraintViolationException
public SQLIntegrityConstraintViolationException()
构造一个SQLIntegrityConstraintViolationException对象。 的reason,SQLState被初始化为null和供应商代码被初始化为0。cause没有初始化,随后可以通过向一个呼叫进行初始化Throwable.initCause(java.lang.Throwable)方法。- 从以下版本开始:
- 1.6
-
SQLIntegrityConstraintViolationException
public SQLIntegrityConstraintViolationException(String reason)
构造一个SQLIntegrityConstraintViolationException与给定的reason。SQLState初始化为null,供应商代码初始化为0.cause未初始化,随后可以通过调用Throwable.initCause(java.lang.Throwable)方法进行初始化。- 参数
-
reason- 异常的描述 - 从以下版本开始:
- 1.6
-
SQLIntegrityConstraintViolationException
public SQLIntegrityConstraintViolationException(String reason, String SQLState)
使用给定的reason和SQLState构造一个SQLIntegrityConstraintViolationException对象。cause未初始化,可以随后通过调用Throwable.initCause(java.lang.Throwable)方法进行初始化。 供应商代码初始化为0。- 参数
-
reason- 异常的描述 -
SQLState- 标识异常的XOPEN或SQL:2003代码 - 从以下版本开始:
- 1.6
-
SQLIntegrityConstraintViolationException
public SQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode)
构造一个SQLIntegrityConstraintViolationException与给定对象reason,SQLState和vendorCode。cause未初始化,可以随后通过调用Throwable.initCause(java.lang.Throwable)方法进行初始化。- 参数
-
reason- 异常的描述 -
SQLState- 标识异常的XOPEN或SQL:2003代码 -
vendorCode- 数据库供应商特定的异常代码 - 从以下版本开始:
- 1.6
-
SQLIntegrityConstraintViolationException
public SQLIntegrityConstraintViolationException(Throwable cause)
构造一个SQLIntegrityConstraintViolationException对象与给定的cause。 该SQLState被初始化为null和供应商代码被初始化为0。reason被初始化为null如果cause==null或cause.toString()如果cause!=null。- 参数
-
cause-底层原因SQLException(保存用于由稍后检索getCause()方法); 可能为空,表示原因不存在或未知。 - 从以下版本开始:
- 1.6
-
SQLIntegrityConstraintViolationException
public SQLIntegrityConstraintViolationException(String reason, Throwable cause)
使用给定的reason和cause构造一个SQLIntegrityConstraintViolationException对象。SQLState初始化为null,供应商代码初始化为0。- 参数
-
reason- 异常的描述。 -
cause- (由getCause()方法保存供以后检索); 可能为空,表示原因不存在或未知。 - 从以下版本开始:
- 1.6
-
SQLIntegrityConstraintViolationException
public SQLIntegrityConstraintViolationException(String reason, String SQLState, Throwable cause)
构造一个SQLIntegrityConstraintViolationException与给定对象reason,SQLState和cause。 供应商代码初始化为0。- 参数
-
reason- 异常的描述。 -
SQLState- 标识异常的XOPEN或SQL:2003代码 -
cause- 这个SQLException的基本原因(保存以供getCause()方法稍后检索); 可能为空,表示原因不存在或未知。 - 从以下版本开始:
- 1.6
-
SQLIntegrityConstraintViolationException
public SQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode, Throwable cause)
构造一个SQLIntegrityConstraintViolationException与给定对象reason,SQLState,vendorCode和cause。- 参数
-
reason- 异常的描述 -
SQLState- 标识异常的XOPEN或SQL:2003代码 -
vendorCode- 数据库供应商特定的异常代码 -
cause- (保存为getCause()方法后续检索); 可能为空,表示原因不存在或未知。 - 从以下版本开始:
- 1.6
-
-