derby db的错误代码列表在哪里?

时间:2016-04-22 16:43:11

标签: java sql exception error-handling derby

我正在使用德比数据库。我试图关闭数据库。我收到了:

----- SQLException -----
SQL State:  XJ004
Error Code: 40000
Message:    Database '<db name>' not found.

我可以找到此处列出的SQL状态:http://db.apache.org/derby/docs/10.8/ref/rrefexcept71493.html

列出XJ004: Database '<databaseName>' not found.

但是,我找不到德比的错误代码列表。

错误代码列表在哪里?

1 个答案:

答案 0 :(得分:2)

Derby使用SQLException中的错误代码来表示异常severity

  

JDBC驱动程序为Derby中的所有错误返回SQLExceptions。如果   异常起源于用户类型但本身不是   SQLException,它包含在SQLException中。德比专用   SQLExceptions使用以X开头的SQLState类代码。标准   在适当的情况下,为异常返回SQLState值。

     

Derby数据库异常按严重性分类。严重程度   通过getErrorCode方法调用可以获得SQLException   SQLException。严重程度总结如下。更多   信息,检查javadoc   org.apache.derby.types.ExceptionSeverity:

常数是:

/**
 * NO_APPLICABLE_SEVERITY occurs only when the system was
 * unable to determine the severity.
 */
public static final int NO_APPLICABLE_SEVERITY = 0;
/**
 * WARNING_SEVERITY is associated with SQLWarnings.
 */
public static final int WARNING_SEVERITY = 10000;
/**
 * STATEMENT_SEVERITY is associated with errors which
 * cause only the current statement to be aborted.
 */
public static final int STATEMENT_SEVERITY = 20000;
/**
 * TRANSACTION_SEVERITY is associated with those errors which
 * cause the current transaction to be aborted.
 */
public static final int TRANSACTION_SEVERITY = 30000;
/**
 * SESSION_SEVERITY is associated with errors which
 * cause the current connection to be closed.
 */
public static final int SESSION_SEVERITY = 40000;
/**
 * DATABASE_SEVERITY is associated with errors which
 * cause the current database to be closed.
 */
public static final int DATABASE_SEVERITY = 45000;
/**
 * SYSTEM_SEVERITY is associated with internal errors which
 * cause the system to shut down.
 */
public static final int SYSTEM_SEVERITY = 50000;