2009-10-28 38 views
0

我有一個Java項目連接到Ingres數據庫並使用Spring框架。此問題與錯誤代碼列表配置有關。Spring-Ingres RDBMS支持sql-error-codes.xml錯誤代碼映射文件

根據Spring Framework API

類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> 

任何人都可以提出一個更先進的日期和完整版?

+0

所以你想要一個更完整的錯誤代碼映射,或者你想知道如何使用上述映射? – skaffman 2009-10-28 14:01:40

+0

首先,我想要一個更完整的代碼映射,如果可能的話從一個有信譽的來源。接下來,我需要將它與已經存在於spring.jar中的那個「合併」,但這是另一回事。 – Adrian 2009-10-28 14:07:33

回答

1

9.3的SQLState代碼可以從docs.ingres.com獲得。從與提交JIRA ticket的人交談起,沒有進一步的更新。大多數錯誤都是使用適當的異常類型處理的。類似於PostgreSQL配置文件。

0

從安格爾9.3文檔中提取適合你的SQL狀態值和一般錯誤代碼

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

+0

我已經提到了包含錯誤代碼的附錄 - 但是我需要Spring Framework所需的文件sql-error-codes.xml – Adrian 2009-10-28 14:24:31

+0

是的,但是你引用了Ingres 2006而不是9.3 – jitter 2009-10-28 14:26:44

+0

這些錯誤代碼在版本之間差不多,特別是對於比原生Ingres錯誤代碼更通用的SQL狀態。 – grantc 2009-11-05 15:20:15

相關問題