FileDocCategorySizeDatePackage
SQLException.javaAPI DocAndroid 1.5 API6125Wed May 06 22:41:06 BST 2009java.sql

SQLException

public class SQLException extends Exception implements Serializable
An {@code Exception} class that is used in conjunction with JDBC operations. It provides information about problems encountered with database access and other problems related to JDBC

The {@code SQLException} class provides the following information:

  • A standard Java exception message, as a {@code String}
  • An {@code SQLState} string. This is an error description string which follows either the SQL 99 conventions or the X/OPEN {@code SQLstate} conventions. The potential values of the {@code SQLState} string are described in each of the specifications. Which of the conventions is being used by the {@code SQLState} string can be discovered by using the {@code getSQLStateType} method of the {@code DatabaseMetaData} interface.
  • An error code, an an integer. The error code is specific to each database vendor and is typically the error code returned by the database itself.
  • A chain to a next {@code Exception}, if relevant, which can give access to additional error information.

see
DatabaseMetaData
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
private String
SQLState
private int
vendorCode
private SQLException
next
Constructors Summary
public SQLException()
Creates an {@code SQLException} object. The reason string is set to {@code null}, the {@code SQLState} string is set to {@code null} and the error code is set to 0.


                                       
      
        super();
    
public SQLException(String theReason)
Creates an {@code SQLException} object. The reason string is set to the given reason string, the {@code SQLState} string is set to {@code null} and the error code is set to 0.

param
theReason the string to use as the Reason string

        this(theReason, null, 0);
    
public SQLException(String theReason, String theSQLState)
Creates an {@code SQLException} object. The reason string is set to the given reason string, the {@code SQLState} string is set to the given {@code SQLState} string and the error code is set to 0.

param
theReason the string to use as the reason string.
param
theSQLState the string to use as the {@code SQLState} string.
since
Android 1.0

        this(theReason, theSQLState, 0);
    
public SQLException(String theReason, String theSQLState, int theErrorCode)
Creates an {@code SQLException} object. The reason string is set to the given reason string, the {@code SQLState} string is set to the given {@code SQLState} string and the error code is set to the given error code value.

param
theReason the string to use as the reason string.
param
theSQLState the string to use as the {@code SQLState} string.
param
theErrorCode the integer value for the error code.
since
Android 1.0

        super(theReason);
        SQLState = theSQLState;
        vendorCode = theErrorCode;
    
Methods Summary
public intgetErrorCode()
Returns the integer error code for this {@code SQLException}.

return
The integer error code for this {@code SQLException}. The meaning of the code is specific to the vendor of the database.
since
Android 1.0

        return vendorCode;
    
public java.sql.SQLExceptiongetNextException()
Retrieves the {@code SQLException} chained to this {@code SQLException}, if any.

return
The {@code SQLException} chained to this {@code SQLException}. {@code null} if there is no {@code SQLException} chained to this {@code SQLException}.

        return next;
    
public java.lang.StringgetSQLState()
Retrieves the {@code SQLState} description string for this {@code SQLException} object.

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

        return SQLState;
    
public voidsetNextException(java.sql.SQLException ex)
Adds the SQLException to the end of this {@code SQLException} chain.

param
ex the new {@code SQLException} to be added to the end of the chain.
since
Android 1.0

    
        if (next != null) {
            next.setNextException(ex);
        } else {
            next = ex;
        }