我有一個Java項目連接到Ingres數據庫並使用Spring框架。此問題與錯誤代碼列表配置有關。Spring-Ingres RDBMS支持sql-error-codes.xml錯誤代碼映射文件
類SQLErrorCodes:JavaBean的用於爲 特定數據庫 保持JDBC錯誤代碼。這個 類的實例通常通過一個 豆工廠加載。
由Spring's使用 SQLErrorCodeSQLExceptionTranslator。 此 程序包中的文件「sql-error-codes.xml」包含各種數據庫的默認SQLErrorCodes 實例。
默認的文件中的spring.jar捆綁,不包括與安格爾RDBMS相關的錯誤代碼,它的位置是org/springframework/jdbc/support/sql-error-codes.xml
本文檔「Ingres 2006 SQL Reference Guide」,附錄d:SQLSTATE值和一般錯誤代碼包含Ingres RDBMS錯誤代碼的完整列表。
含入口錯誤代碼SQL的錯誤codes.xml文件的唯一相關的樣本是這樣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>
任何人都可以提出一個更先進的日期和完整版?
所以你想要一個更完整的錯誤代碼映射,或者你想知道如何使用上述映射? – skaffman 2009-10-28 14:01:40
首先,我想要一個更完整的代碼映射,如果可能的話從一個有信譽的來源。接下來,我需要將它與已經存在於spring.jar中的那個「合併」,但這是另一回事。 – Adrian 2009-10-28 14:07:33