Results 1 to 3 of 3

Thread: SQLException translation question

  1. #1
    Join Date
    May 2007
    Posts
    15

    Default 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());

  2. #2
    Join Date
    Aug 2004
    Posts
    1,104

    Default

    It's probably using the fall-back which is using the SQL STATE from the SQLException.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  3. #3
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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
  •