views:

429

answers:

2

I have a Java project connecting to an Ingres database and using the Spring Framework. This issue is related to the error codes list configuration.

According to Spring Framework API:

Class SQLErrorCodes: JavaBean for holding JDBC error codes for a particular database. Instances of this class are normally loaded through a bean factory.

Used by Spring's SQLErrorCodeSQLExceptionTranslator. The file "sql-error-codes.xml" in this package contains default SQLErrorCodes instances for various databases.

The default file is bundled in spring.jar, does not include error codes associated with Ingres RDBMS and it’s location is org/springframework/jdbc/support/sql-error-codes.xml

This document "Ingres 2006 SQL Reference Guide", in Appendix D: SQLSTATE Values and Generic Error Codes, contains the complete list of Ingres RDBMS error codes.

The only relevant sample of sql-error-codes.xml file containing Ingress error codes is this one:

Quote:

<?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"&gt;

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

Can anyone suggest a more up-to-date and complete version?

A: 

Extracted from the Ingres 9.3 documentation for you the SQL State Values and Generic Error Codes

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

jitter
I already mentioned the Appendix containing the error codes - but I need the file sql-error-codes.xml as required by Spring Framework
Adrian
Yeah but you referenced Ingres 2006 instead of 9.3
jitter
The error codes are much the same between releases, especially for the SQL State which is more generic than the native Ingres error codes.
grantc
Correct and btw I don't think you can use the sql-error-codes.xml to handle native error codes
jitter
+1  A: 

The 9.3 SQLState codes can be obtained from docs.ingres.com. From speaking with the person who submitted the JIRA ticket there have been no further updates. Most errors are handled with the appropriate exception type. Similar to the PostgreSQL profile.

grantc