SQLExceptionpublic class SQLException extends Exception implements SerializableAn {@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.
|
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.
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.
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.
super(theReason);
SQLState = theSQLState;
vendorCode = theErrorCode;
|
Methods Summary |
---|
public int | getErrorCode()Returns the integer error code for this {@code SQLException}.
return vendorCode;
| public java.sql.SQLException | getNextException()Retrieves the {@code SQLException} chained to this {@code SQLException},
if any.
return next;
| public java.lang.String | getSQLState()Retrieves the {@code SQLState} description string for this {@code
SQLException} object.
return SQLState;
| public void | setNextException(java.sql.SQLException ex)Adds the SQLException to the end of this {@code SQLException} chain.
if (next != null) {
next.setNextException(ex);
} else {
next = ex;
}
|
|