Skip to content

Most visited

Recently visited

navigation
Added in API level 1

SQLException

public class SQLException
extends Exception implements Serializable, Iterable<Throwable>

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


An exception that indicates a failed JDBC operation. It provides the following information about problems encountered with database access:

See also:

Summary

Public constructors

SQLException()

Creates an SQLException object.

SQLException(String theReason)

Creates an SQLException object.

SQLException(String theReason, String theSQLState)

Creates an SQLException object.

SQLException(String theReason, String theSQLState, int theErrorCode)

Creates an SQLException object.

SQLException(Throwable theCause)

Creates an SQLException object.

SQLException(String theReason, Throwable theCause)

Creates an SQLException object.

SQLException(String theReason, String theSQLState, Throwable theCause)

Creates an SQLException object.

SQLException(String theReason, String theSQLState, int theErrorCode, Throwable theCause)

Creates an SQLException object.

Public methods

int getErrorCode()

Returns the integer error code for this SQLException.

SQLException getNextException()

Retrieves the SQLException chained to this SQLException, if any.

String getSQLState()

Retrieves the SQLState description string for this SQLException object.

Iterator<Throwable> iterator()

Obsolete.

void setNextException(SQLException ex)

Obsolete.

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 ()

Creates an SQLException object. The reason string is set to null, the SQLState string is set to null and the error code is set to 0.

SQLException

Added in API level 1
SQLException (String theReason)

Creates an SQLException object. The reason string is set to the given reason string, the SQLState string is set to null and the error code is set to 0.

Parameters
theReason String: the string to use as the Reason string

SQLException

Added in API level 1
SQLException (String theReason, 
                String theSQLState)

Creates an SQLException object. The reason string is set to the given reason string, the SQLState string is set to the given SQLState string and the error code is set to 0.

Parameters
theReason String: the string to use as the reason string.
theSQLState String: the string to use as the SQLState string.

SQLException

Added in API level 1
SQLException (String theReason, 
                String theSQLState, 
                int theErrorCode)

Creates an SQLException object. The reason string is set to the given reason string, the SQLState string is set to the given SQLState string and the error code is set to the given error code value.

Parameters
theReason String: the string to use as the reason string.
theSQLState String: the string to use as the SQLState string.
theErrorCode int: the integer value for the error code.

SQLException

Added in API level 9
SQLException (Throwable theCause)

Creates an SQLException object. The Reason string is set to the null if cause == null or cause.toString() if cause!=null,and the cause Throwable object is set to the given cause Throwable object.

Parameters
theCause Throwable: the Throwable object for the underlying reason this SQLException

SQLException

Added in API level 9
SQLException (String theReason, 
                Throwable theCause)

Creates an SQLException object. The Reason string is set to the given and the cause Throwable object is set to the given cause Throwable object.

Parameters
theReason String: the string to use as the Reason string
theCause Throwable: the Throwable object for the underlying reason this SQLException

SQLException

Added in API level 9
SQLException (String theReason, 
                String theSQLState, 
                Throwable theCause)

Creates an SQLException object. The Reason string is set to the given reason string, the SQLState string is set to the given SQLState string and the cause Throwable object is set to the given cause Throwable object.

Parameters
theReason String: the string to use as the Reason string
theSQLState String: the string to use as the SQLState string
theCause Throwable: the Throwable object for the underlying reason this SQLException

SQLException

Added in API level 9
SQLException (String theReason, 
                String theSQLState, 
                int theErrorCode, 
                Throwable theCause)

Creates an SQLException object. The Reason string is set to the given reason string, the SQLState string is set to the given SQLState string , the Error Code is set to the given error code value, and the cause Throwable object is set to the given cause Throwable object.

Parameters
theReason String: the string to use as the Reason string
theSQLState String: the string to use as the SQLState string
theErrorCode int: the integer value for the error code
theCause Throwable: the Throwable object for the underlying reason this SQLException

Public methods

getErrorCode

Added in API level 1
int getErrorCode ()

Returns the integer error code for this SQLException.

Returns
int The integer error code for this SQLException. The meaning of the code is specific to the vendor of the database.

getNextException

Added in API level 1
SQLException getNextException ()

Retrieves the SQLException chained to this SQLException, if any.

Returns
SQLException The SQLException chained to this SQLException. null if there is no SQLException chained to this SQLException.

getSQLState

Added in API level 1
String getSQLState ()

Retrieves the SQLState description string for this SQLException object.

Returns
String The SQLState string for this SQLException object. This is an error description string which follows either the SQL 99 conventions or the X/OPEN SQLstate conventions. The potential values of the SQLState string are described in each of the specifications. Which of the conventions is being used by the SQLState string can be discovered by using the getSQLStateType method of the DatabaseMetaData interface.

iterator

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

Obsolete. getCause() should be used instead of this iterator. Returns an iterator over the exceptions added with setNextException(SQLException).

Returns
Iterator<Throwable> An Iterator instance.

setNextException

Added in API level 1
void setNextException (SQLException ex)

Obsolete. Appends ex to the end of this chain.

Parameters
ex SQLException
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.