Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

SQLException

extends Exception
implements Serializable Iterable <T>
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.sql.SQLException
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

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

  • A message string.
  • A SQLState error description string following either SQL 99 or X/OPEN SQLState conventions. getSQLStateType() exposes the specific convention in use.
  • A database-specific error code.
  • The next exception in the chain.

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.
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object
From interface java.lang.Iterable

Public Constructors

public SQLException ()

Added in API level 1

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.

public SQLException ( String theReason)

Added in API level 1

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 the string to use as the Reason string

public SQLException ( String theReason, String theSQLState)

Added in API level 1

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 the string to use as the reason string.
theSQLState the string to use as the SQLState string.

public SQLException ( String theReason, String theSQLState, int theErrorCode)

Added in API level 1

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 the string to use as the reason string.
theSQLState the string to use as the SQLState string.
theErrorCode the integer value for the error code.

public SQLException ( Throwable theCause)

Added in API level 9

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 the Throwable object for the underlying reason this SQLException

public SQLException ( String theReason, Throwable theCause)

Added in API level 9

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 the string to use as the Reason string
theCause the Throwable object for the underlying reason this SQLException

public SQLException ( String theReason, String theSQLState, Throwable theCause)

Added in API level 9

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 the string to use as the Reason string
theSQLState the string to use as the SQLState string
theCause the Throwable object for the underlying reason this SQLException

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

Added in API level 9

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 the string to use as the Reason string
theSQLState the string to use as the SQLState string
theErrorCode the integer value for the error code
theCause the Throwable object for the underlying reason this SQLException

Public Methods

public int getErrorCode ()

Added in API level 1

Returns the integer error code for this SQLException .

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

public SQLException getNextException ()

Added in API level 1

Retrieves the SQLException chained to this SQLException , if any.

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

public String getSQLState ()

Added in API level 1

Retrieves the SQLState description string for this SQLException object.

Returns
  • 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.

public Iterator < Throwable > iterator ()

Added in API level 9

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

Returns
  • An Iterator instance.

public void setNextException ( SQLException ex)

Added in API level 1

Obsolete. Appends ex to the end of this chain.