Most visited

Recently visited

Added in API level 1

SQLException

public class SQLException
extends 异常 implements Iterable<Throwable>

java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.sql.SQLException
Known Direct Subclasses
Known Indirect Subclasses


提供有关数据库访问错误或其他错误信息的例外。

每个 SQLException提供几种信息:

Summary

Public constructors

SQLException(String reason, String SQLState, int vendorCode)

构造一个 SQLException与给定对象 reasonSQLStatevendorCode

SQLException(String reason, String SQLState)

用给定的 reasonSQLState构造一个 SQLException对象。

SQLException(String reason)

用给定的 reason构造一个 SQLException对象。

SQLException()

构造一个 SQLException对象。

SQLException(Throwable cause)

用给定的 cause构造一个 SQLException对象。

SQLException(String reason, Throwable cause)

用给定的 reasoncause构造一个 SQLException对象。

SQLException(String reason, String sqlState, Throwable cause)

构造一个 SQLException与给定对象 reasonSQLStatecause

SQLException(String reason, String sqlState, int vendorCode, Throwable cause)

构造一个 SQLException与给定对象 reasonSQLStatevendorCodecause

Public methods

int getErrorCode()

检索此 SQLException对象的供应商特定的例外代码。

SQLException getNextException()

通过setNextException(SQLException ex)检索链接到此 SQLException对象的异常。

String getSQLState()

检索此 SQLException对象的SQLState。

Iterator<Throwable> iterator()

返回链式SQLException上的迭代器。

void setNextException(SQLException ex)

将一个 SQLException对象添加到链的末尾。

Inherited methods

From class java.lang.Throwable
From class java.lang.Object
From interface java.lang.Iterable

Public constructors

SQLException

Added in API level 1
SQLException (String reason, 
                String SQLState, 
                int vendorCode)

构造一个SQLException与给定对象reasonSQLStatevendorCode 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

Added in API level 1
SQLException (String reason, 
                String SQLState)

用给定的reasonSQLState构造一个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

Added in API level 1
SQLException (String reason)

用给定的reason构造一个SQLException对象。 SQLState初始化为null ,并且供应商代码初始化为cause未初始化,并可能随后通过调用initCause(java.lang.Throwable)方法进行初始化。

Parameters
reason String: a description of the exception

SQLException

Added in API level 1
SQLException ()

构造一个SQLException对象。 reasonSQLState被初始化为null和供应商代码被初始化为0。 cause没有初始化,随后可以通过向一个呼叫进行初始化initCause(java.lang.Throwable)方法。

SQLException

Added in API level 9
SQLException (Throwable cause)

用给定的cause构造一个SQLException对象。 SQLState初始化为null ,供应商代码初始化为0. reason初始化为null如果为cause==nullcause.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

Added in API level 9
SQLException (String reason, 
                Throwable cause)

用给定的reasoncause构造一个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

Added in API level 9
SQLException (String reason, 
                String sqlState, 
                Throwable cause)

构造一个SQLException与给定对象reasonSQLStatecause 供应商代码初始化为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

Added in API level 9
SQLException (String reason, 
                String sqlState, 
                int vendorCode, 
                Throwable cause)

构造一个 SQLException与给定对象 reasonSQLStatevendorCodecause

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.

Public methods

getErrorCode

Added in API level 1
int getErrorCode ()

检索此 SQLException对象的供应商特定的例外代码。

Returns
int the vendor's error code

getNextException

Added in API level 1
SQLException getNextException ()

通过setNextException(SQLException ex)检索链接到此 SQLException对象的异常。

Returns
SQLException the next SQLException object in the chain; null if there are none

也可以看看:

getSQLState

Added in API level 1
String getSQLState ()

检索此 SQLException对象的SQLState。

Returns
String the SQLState value

iterator

Added in API level 9
Iterator<Throwable> iterator ()

返回链式SQLException上的迭代器。 迭代器将用于遍历每个SQLException及其基础原因(如果有的话)。

Returns
Iterator<Throwable> an iterator over the chained SQLExceptions and causes in the proper order

setNextException

Added in API level 1
void setNextException (SQLException ex)

将一个 SQLException对象添加到链的末尾。

Parameters
ex SQLException: the new exception that will be added to the end of the SQLException chain

也可以看看:

Hooray!