-
May 14th, 2007, 03:06 AM
#1
SQLException translation question
hi
I'm planning on using Spring 2.0 exception hierarchy in an application that uses JPA for data access. The system runs on Oracle OC4J.
I'm using SQLErrorCodeSQLExceptionTranslator for translating SQLExceptions to Spring DataAccessExceptions. How does the translator figure out the required translations? Aren't the translations configured in the sql-error-codes.xml file?
The translation is doing the right thing but I'm a bit puzzled about how it manages to translate an SQLException with error code 907 (ORA-00907: missing right parenthesis) into a BadSqlGrammarException when the SQLErrorCodes badSqlGrammarCodes property is configured (sql-error-codes.xml) with the following list: 900,903,904,917,936,942,17006.
Here's the code I'm using for translation:
SQLErrorCodeSQLExceptionTranslator translator = new SQLErrorCodeSQLExceptionTranslator("Oracle");
DataAccessException e = translator.translate("getParameterValueSets",
"select * from foo", (SQLException)ex.getCause());
-
May 14th, 2007, 06:35 AM
#2
It's probably using the fall-back which is using the SQL STATE from the SQLException.
-
May 14th, 2007, 06:48 AM
#3
Indeed. There is a fallback instance of SQLStateSQLExceptionTranslator wherein common SQL states are categorized.
So the exception in question should have one of the SQL states 07, 37, 42, 2A, 65 or S0
Regards,
Andreas
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules