代码之家  ›  专栏  ›  技术社区  ›  Adrian

sql-error-codes.xml错误代码映射文件中的Spring-Ingres RDBMS支持

  •  0
  • Adrian  · 技术社区  · 15 年前

    我有一个使用Spring框架连接到Ingres数据库的Java项目。此问题与错误代码列表配置有关。

    Spring Framework API :

    类SQLErrorCodes:JavaBean for 特定数据库。这方面的例子 豆子工厂。

    由斯普林公司使用 SQLErrorCodeSQLExceptionTranslator。 此文件中的文件“sql error codes.xml” 包包含默认的SQLErrorCodes 各种数据库的实例。

    org/springframework/jdbc/support/sql-error-codes.xml

    本文件“ Ingres 2006 SQL Reference Guide “,在附录D:SQLSTATE值和通用错误代码中,包含了安格尔RDBMS错误代码的完整列表。

    one :

    引述:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
    
    <!--
        - Default SQL error codes for well-known databases.
        - Can be overridden by definitions in a "sql-error-codes.xml" file
        - in the root of the class path.
        -
        - If the Database Product Name contains characters that are invalid
        - to use in the id attribute (like a space) then we need to add a property
        - named "databaseProductName"/"databaseProductNames" that holds this value.
        - If this property is present, then it will be used instead of the id for
        - looking up the error codes based on the current database.
        -->
    <beans>
        <bean id="INGRES" class="org.springframework.jdbc.support.SQLErrorCodes">
            <property name="useSqlStateForTranslation">
                <value>true</value>
            </property>
            <property name="badSqlGrammarCodes">
                <value>22000,26000,42000,42500,42501,50000,5000A</value>
            </property>
            <property name="invalidResultSetAccessCodes">
                <value>24000</value>
            </property>
            <property name="dataIntegrityViolationCodes">
                <value>23500,23501,23502</value>
            </property>
            <property name="dataAccessResourceFailureCodes">
                <value>08001</value>
            </property>
            <property name="cannotAcquireLockCodes">
                <value>5000R</value>
            </property>
            <property name="cannotSerializeTransactionCodes">
                <value>40001</value>
            </property>
            <property name="deadlockLoserCodes">
                <value>40P01</value>
            </property>
        </bean>
    
    </beans>
    

    有人能推荐一个更新、更完整的版本吗?

    2 回复  |  直到 12 年前
        1
  •  1
  •   grantc    15 年前

    9.3 SQLState代码可从 docs.ingres.com . 与提交申请的人交谈 JIRA ticket 没有进一步的更新。大多数错误都使用适当的异常类型处理。类似于PostgreSQL概要文件。

        2
  •  0
  •   jitter    15 年前

    从Ingres 9.3文档中为您提取SQL状态值和一般错误代码

    Ingres 9.3 SQL Reference Guide - Appendix C: SQLSTATE Values and Generic Error Codes