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;
  17. import java.sql.SQLException;
  18. import org.springframework.dao.UncategorizedDataAccessException;
  19. /**
  20. * Exception thrown when we can't classify a SQLException into
  21. * one of our generic data access exceptions.
  22. * @author Rod Johnson
  23. * @version $Id: UncategorizedSQLException.java,v 1.3 2004/03/18 02:46:16 trisberg Exp $
  24. */
  25. public class UncategorizedSQLException extends UncategorizedDataAccessException {
  26. /** SQL that led to the problem */
  27. private final String sql;
  28. /**
  29. * Constructor for ConnectionFactoryException.
  30. * @param msg message
  31. * @param sql SQL we were tring to execute
  32. * @param ex SQLException
  33. */
  34. public UncategorizedSQLException(String msg, String sql, SQLException ex) {
  35. super(msg, ex);
  36. this.sql = sql;
  37. }
  38. /**
  39. * Return the underlying SQLException.
  40. */
  41. public SQLException getSQLException() {
  42. return (SQLException) getCause();
  43. }
  44. /**
  45. * Return the SQL that led to the problem.
  46. */
  47. public String getSql() {
  48. return sql;
  49. }
  50. }