接口 SQLExceptionTranslator

    • 方法详细资料

      • translate

        DataAccessException translate​(String task,
                                      String sql,
                                      SQLException ex)
        Translate the given SQLException into a generic DataAccessException.

        The returned DataAccessException is supposed to contain the original SQLException as root cause. However, client code may not generally rely on this due to DataAccessExceptions possibly being caused by other resource APIs as well. That said, a getRootCause() instanceof SQLException check (and subsequent cast) is considered reliable when expecting JDBC-based access to have happened.

        参数:
        task - readable text describing the task being attempted
        sql - the SQL query or update that caused the problem (if known)
        ex - the offending SQLException
        返回:
        the DataAccessException wrapping the SQLException, or null if no translation could be applied (in a custom translator; the default translators always throw an UncategorizedSQLException in such a case)
        另请参阅:
        NestedRuntimeException.getRootCause()