27.10.2013 Views

Jaybird 2.1 JDBC driver Java Programmer's Manual - Firebird

Jaybird 2.1 JDBC driver Java Programmer's Manual - Firebird

Jaybird 2.1 JDBC driver Java Programmer's Manual - Firebird

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

class are thrown by the GDS implementations. Upper layers either convert these<br />

exceptions into the ones appropriate to that layer or catch them if <strong>driver</strong> can<br />

handle the error condition.<br />

• Subclasses of javax.resource.ResourceException are thrown by the JCA<br />

layer when an error happens in the JCA-related code. Upper layer converts this<br />

exception into a subclass of java.sql.SQLException. If the<br />

ResourceException was caused by the GDSException, latter is extracted<br />

during conversion preserving the error code. If ResourceException was<br />

caused by an error condition not related to an error returned by the database<br />

engine, error code of the SQLException remains 0.<br />

• Subclasses of javax.transaction.XAException are thrown when an XA<br />

protocol error happens in JCA layer. Similar to the previous case, XAException<br />

can wrap the GDSException, which are extracted during exception conversion<br />

to preserve the error code.<br />

• Subclasses of java.sql.SQLException are thrown by the <strong>JDBC</strong> layer. Driver<br />

has also few subclasses that might be interesting to the application:<br />

• org.firebirdsql.jdbc.FBDriverConsistencyCheckException – this<br />

exception is thrown when <strong>driver</strong> detects an internal inconsistent state. SQL<br />

state is SQL_STATE_GENERAL_ERROR.<br />

• org.firebirdsql.jdbc.FBDriverNotCapableException – this exception<br />

is thrown when an unsupported method is called. SQL state is<br />

SQL_STATE_DRIVER_NOT_CAPABLE.<br />

• org.firebirdsql.jdbc.FBSQLParseException – this exception is thrown<br />

when incorrect escaped syntax is detected. SQL state is<br />

SQL_STATE_INVALID_ESCAPE_SEQ.<br />

• org.firebirdsql.jdbc.field.TypeConversionException – this<br />

exception is thrown when the <strong>driver</strong> is asked to perform a type conversion<br />

that is not defined in the <strong>JDBC</strong> specification. For a table of allowed type<br />

conversions see Ошибка: источник перекрестной ссылки не найден.<br />

SQL states<br />

<strong>Jaybird</strong> supports the SQL states from the X/Open standard, however only few<br />

states nicely map into the <strong>Firebird</strong> error codes. Below is the table containing the<br />

reported SQL states.<br />

Constant name Constant value<br />

SQL_STATE_INVALID_CON_ATTR "01S00"<br />

SQL_STATE_NO_ROW_AVAIL "01S06"<br />

SQL_STATE_GENERAL_ERROR "HY00"<br />

SQL_STATE_DRIVER_NOT_CAPABLE "HYC00"<br />

SQL_STATE_INVALID_COLUMN "HY02"<br />

SQL_STATE_INVALID_PARAM_TYPE "HY105"<br />

SQL_STATE_INVALID_ARG_VALUE "HY009"<br />

Chapter 3. Handling exceptions 27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!