java.lang.Objectjava.lang.Throwable
java.lang.Exception
java.sql.SQLException
提供关于数据库访问错误或其他错误信息的异常。
每个 SQLException 都可提供以下多种消息:
getMessage 获得。 DatabaseMetaData 的方法 getSQLStateType 可用于确定驱动程序返回 XOPEN 类型还是 SQL:2003 类型。 SQLException 的原因。
| 构造方法摘要 | |
|---|---|
SQLException() 构造一个 SQLException 对象。 |
|
SQLException(String reason) 构造一个具有给定 reason 的 SQLException 对象。 |
|
SQLException(String reason, String SQLState) 构造一个具有给定 reason 和 SQLState 的 SQLException 对象。 |
|
SQLException(String reason, String SQLState, int vendorCode) 构造一个具有给定 reason、SQLState 和 vendorCode 的 SQLException 对象。 |
|
SQLException(String reason, String sqlState, int vendorCode, Throwable cause) 构造一个具有给定 reason、SQLState、vendorCode 和 cause 的 SQLException 对象。 |
|
SQLException(String reason, String sqlState, Throwable cause) 构造一个具有给定 reason、SQLState 和 cause 的 SQLException 对象。 |
|
SQLException(String reason, Throwable cause) 构造一个具有给定 reason 和 cause 的 SQLException 对象。 |
|
SQLException(Throwable cause) 构造一个具有给定 cause 的 SQLException 对象。 |
|
| 方法摘要 | |
|---|---|
int |
getErrorCode() 获取此 SQLException 对象的特定于供应商的异常代码。 |
SQLException |
getNextException() 通过 setNextException(SQLException ex) 获取链接到此 SQLException 对象的异常。 |
String |
getSQLState() 获取此 SQLException 对象的 SQLState。 |
Iterator<Throwable> |
iterator() 返回在链接的 SQLExceptions 上进行迭代的迭代器。 |
void |
setNextException(SQLException ex) 将 SQLException 对象添加到链接的末尾。 |
| 从类 java.lang.Throwable 继承的方法 |
|---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 构造方法详细信息 |
|---|
public SQLException(String reason, String SQLState, int vendorCode)
reason、
SQLState 和
vendorCode 的
SQLException 对象。
cause 没有初始化,随后可调用
Throwable.initCause(java.lang.Throwable) 方法初始化。
reason - 对异常的描述
SQLState - 标识异常的 XOPEN 或 SQL:2003 代码
vendorCode - 特定于数据库供应商的异常代码
public SQLException(String reason, String SQLState)
reason 和
SQLState 的
SQLException 对象。
cause 没有初始化,随后可调用
Throwable.initCause(java.lang.Throwable) 方法初始化。供应商代码被初始化为 0。
reason - 对异常的描述
SQLState - 标识异常的 XOPEN 或 SQL:2003 代码
public SQLException(String reason)
reason 的
SQLException 对象。
SQLState 被初始化为
null,供应商代码被初始化为 0。
cause 没有初始化,随后可调用
Throwable.initCause(java.lang.Throwable) 方法初始化。
reason - 对异常的描述
public SQLException()
SQLException 对象。
reason 和
SQLState 被初始化为
null,供应商代码被初始化为 0。
cause 没有初始化,随后可调用
Throwable.initCause(java.lang.Throwable) 方法初始化。
public SQLException(Throwable cause)
cause 的
SQLException 对象。
SQLState 被初始化为
null,供应商代码被初始化为 0。如果
cause==null,则
reason 被初始化为
null;如果
cause!=null,则初始化为
cause.toString()。
cause - 导致此
SQLException 的底层原因(保存此 cause,以供以后通过
getCause() 方法获取);此参数可以为 null,指示 cause 不存在或未知。
public SQLException(String reason, Throwable cause)
reason 和
cause 的
SQLException 对象。
SQLState 被初始化为
null,供应商代码被初始化为 0。
reason - 对异常的描述。
cause - 导致此
SQLException 的底层原因(保存此 cause,以供以后通过
getCause() 方法获取);此参数可以为 null,指示 cause 不存在或未知。
public SQLException(String reason, String sqlState, Throwable cause)
reason、
SQLState 和
cause 的
SQLException 对象。供应商代码被初始化为 0。
reason - 对异常的描述。
sqlState - 标识异常的 XOPEN 或 SQL:2003 代码
cause - 导致此
SQLException 的底层原因(保存此 cause,以供以后通过
getCause() 方法获取);此参数可以为 null,指示 cause 不存在或未知。
public SQLException(String reason, String sqlState, int vendorCode, Throwable cause)
reason、
SQLState、
vendorCode 和
cause 的
SQLException 对象。
reason - 对异常的描述
sqlState - 标识异常的 XOPEN 或 SQL:2003 代码
vendorCode - 特定于数据库供应商的异常代码
cause - 导致此
SQLException 的底层原因(保存此 cause,以供以后通过
getCause() 方法获取);此参数可以为 null,指示 cause 不存在或未知。
| 方法详细信息 |
|---|
public String getSQLState()
SQLException 对象的 SQLState。
public int getErrorCode()
SQLException 对象的特定于供应商的异常代码。
public SQLException getNextException()
SQLException 对象的异常。
SQLException 对象;如果不存在,则返回
null
setNextException(java.sql.SQLException)
public void setNextException(SQLException ex)
SQLException 对象添加到链接的末尾。
ex - 将添加到
SQLException 链接末尾的新异常
getNextException()
public Iterator<Throwable> iterator()