public class SQLException
extends 异常 implements Iterable<Throwable>
| java.lang.Object | |||
| java.lang.Throwable | |||
| java.lang.Exception | |||
| java.sql.SQLException | |||
| |
| |
提供有关数据库访问错误或其他错误信息的例外。
每个 SQLException提供几种信息:
getMesasge. DatabaseMetaData method getSQLStateType can be used to discover whether the driver returns the XOPEN type or the SQL:2003 type. SQLException. Public constructors |
|
|---|---|
SQLException(String reason, String SQLState, int vendorCode) 构造一个 |
|
SQLException(String reason, String SQLState) 用给定的 |
|
SQLException(String reason) 用给定的 |
|
SQLException() 构造一个 |
|
SQLException(Throwable cause) 用给定的 |
|
SQLException(String reason, Throwable cause) 用给定的 |
|
SQLException(String reason, String sqlState, Throwable cause) 构造一个 |
|
SQLException(String reason, String sqlState, int vendorCode, Throwable cause) 构造一个 |
|
公共方法(Public methods) |
|
|---|---|
int |
getErrorCode() 检索此 |
SQLException |
getNextException() 通过setNextException(SQLException ex)检索链接到此 |
String |
getSQLState() 检索此 |
Iterator<Throwable> |
iterator() 返回链式SQLException上的迭代器。 |
void |
setNextException(SQLException ex) 将一个 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Throwable
|
|
java.lang.Object
|
|
java.lang.Iterable
|
|
SQLException (String reason, String SQLState, int vendorCode)
构造一个SQLException与给定对象reason , SQLState和vendorCode 。 cause未初始化,并可能随后通过调用initCause(java.lang.Throwable)方法进行初始化。
| 参数(Parameters) | |
|---|---|
reason |
String: a description of the exception |
SQLState |
String: an XOPEN or SQL:2003 code identifying the exception |
vendorCode |
int: a database vendor-specific exception code |
SQLException (String reason, String SQLState)
用给定的reason和SQLState构造一个SQLException对象。 cause未初始化,并可能随后通过调用initCause(java.lang.Throwable)方法进行初始化。 供应商代码初始化为0。
| 参数(Parameters) | |
|---|---|
reason |
String: a description of the exception |
SQLState |
String: an XOPEN or SQL:2003 code identifying the exception |
SQLException (String reason)
用给定的reason构造一个SQLException对象。 SQLState初始化为null ,并且供应商代码初始化为cause未初始化,并可能随后通过调用initCause(java.lang.Throwable)方法进行初始化。
| 参数(Parameters) | |
|---|---|
reason |
String: a description of the exception |
SQLException ()
构造一个SQLException对象。 的reason , SQLState被初始化为null和供应商代码被初始化为0。 cause没有初始化,随后可以通过向一个呼叫进行初始化initCause(java.lang.Throwable)方法。
SQLException (Throwable cause)
用给定的cause构造一个SQLException对象。 SQLState初始化为null ,供应商代码初始化为0. reason初始化为null如果为cause==null或cause.toString()如果为null则初始化为cause!=null 。
| 参数(Parameters) | |
|---|---|
cause |
Throwable: the underlying reason for this SQLException (which is saved for later retrieval by the getCause() method); may be null indicating the cause is non-existent or unknown. |
SQLException (String reason, Throwable cause)
用给定的reason和cause构造一个SQLException对象。 SQLState初始化为null ,供应商代码初始化为0。
| 参数(Parameters) | |
|---|---|
reason |
String: a description of the exception. |
cause |
Throwable: the underlying reason for this SQLException (which is saved for later retrieval by the getCause() method); may be null indicating the cause is non-existent or unknown. |
SQLException (String reason, String sqlState, Throwable cause)
构造一个SQLException与给定对象reason , SQLState和cause 。 供应商代码初始化为0。
| 参数(Parameters) | |
|---|---|
reason |
String: a description of the exception. |
sqlState |
String: an XOPEN or SQL:2003 code identifying the exception |
cause |
Throwable: the underlying reason for this SQLException (which is saved for later retrieval by the getCause() method); may be null indicating the cause is non-existent or unknown. |
SQLException (String reason, String sqlState, int vendorCode, Throwable cause)
构造一个 SQLException与给定对象 reason , SQLState , vendorCode和 cause 。
| 参数(Parameters) | |
|---|---|
reason |
String: a description of the exception |
sqlState |
String: an XOPEN or SQL:2003 code identifying the exception |
vendorCode |
int: a database vendor-specific exception code |
cause |
Throwable: the underlying reason for this SQLException (which is saved for later retrieval by the getCause() method); may be null indicating the cause is non-existent or unknown. |
int getErrorCode ()
检索此 SQLException对象的供应商特定的例外代码。
| 返回(Returns) | |
|---|---|
int |
the vendor's error code |
SQLException getNextException ()
通过setNextException(SQLException ex)检索链接到此 SQLException对象的异常。
| 返回(Returns) | |
|---|---|
SQLException |
the next SQLException object in the chain; null if there are none |
String getSQLState ()
检索此 SQLException对象的SQLState。
| 返回(Returns) | |
|---|---|
String |
the SQLState value |
Iterator<Throwable> iterator ()
返回链式SQLException上的迭代器。 迭代器将用于遍历每个SQLException及其基础原因(如果有的话)。
| 返回(Returns) | |
|---|---|
Iterator<Throwable> |
an iterator over the chained SQLExceptions and causes in the proper order |
void setNextException (SQLException ex)
将一个 SQLException对象添加到链的末尾。
| 参数(Parameters) | |
|---|---|
ex |
SQLException: the new exception that will be added to the end of the SQLException chain |
也可以看看: