/*
 * Copyright 2002-2005 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.jdbc;

import java.sql.SQLException;

import org.springframework.dao.UncategorizedDataAccessException;

/**
 * Exception thrown when we can't classify a SQLException into 
 * one of our generic data access exceptions.
 *
 * @author Rod Johnson
 */
public class UncategorizedSQLException extends UncategorizedDataAccessException {
	
	/** SQL that led to the problem */
	private String sql;

	/**
	 * Constructor for ConnectionFactoryException.
	 * @param msg message
	 * @param sql SQL we were tring to execute
	 * @param ex SQLException
	 */
	public UncategorizedSQLException(String msg, String sql, SQLException ex) {
		super(msg, ex);
		this.sql = sql;
	}
	
	/**
	 * Return the underlying SQLException.
	 */
	public SQLException getSQLException() {
		return (SQLException) getCause();
	}
	
	/**
	 * Return the SQL that led to the problem.
	 */
	public String getSql() {
		return sql;
	}

}

@@ -890,16 +890,43 @@
 Johnson%0A
+ * @author Juergen Hoeller%0A
  */%0Apubl
@@ -1050,16 +1050,22 @@
 private 
+final 
 String s
@@ -1098,25 +1098,24 @@
 for 
-ConnectionFactory
+UncategorizedSQL
 Exce
@@ -1136,63 +1136,76 @@
 ram 
-msg message%0A%09 * @param sql SQL we were tring to execute
+task name of current task%0A%09 * @param sql the offending SQL statement
 %0A%09 *
@@ -1215,28 +1215,30 @@
 aram ex 
-SQLException
+the root cause
 %0A%09 */%0A%09p
@@ -1276,19 +1276,20 @@
 (String 
-msg
+task
 , String
@@ -1325,11 +1325,169 @@
 per(
-msg
+task + %22; uncategorized SQLException for SQL %5B%22 + sql + %22%5D; SQL state %5B%22 +%0A%09%09%09%09ex.getSQLState() + %22%5D; error code %5B%22 + ex.getErrorCode() + %22%5D; %22 + ex.getMessage()
 , ex
@@ -1506,25 +1506,24 @@
 l = sql;%0A%09%7D%0A
-%09
 %0A%09/**%0A%09 * Re

include SQL state and error code in message, to indicate potential exception classification