1. /*
  2. * Copyright 2002-2004 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.jdbc.support;
  17. import java.sql.SQLException;
  18. import org.springframework.dao.DataAccessException;
  19. /**
  20. * Interface to be implemented by classes that can translate
  21. * between SQLExceptions and our data access strategy-agnostic
  22. * org.springframework.dao.DataAccessException.
  23. *
  24. * <p>Implementations can be generic (for example, using SQLState
  25. * codes for JDBC) or proprietary (for example, using Oracle
  26. * error codes) for greater precision.
  27. *
  28. * @author Rod Johnson
  29. * @see org.springframework.dao.DataAccessException
  30. * @version $Id: SQLExceptionTranslator.java,v 1.2 2004/03/18 02:46:15 trisberg Exp $
  31. */
  32. public interface SQLExceptionTranslator {
  33. /**
  34. * Translate the given SQL exception into a generic
  35. * data access exception.
  36. * @param task readable text describing the task being attempted
  37. * @param sql SQL query or update that caused the problem.
  38. * May be null.
  39. * @param sqlex SQLException encountered by JDBC implementation
  40. */
  41. DataAccessException translate(String task, String sql, SQLException sqlex);
  42. }