FileDocCategorySizeDatePackage
JDBCExceptionReporter.javaAPI DocHibernate 3.2.52832Tue Oct 31 14:24:28 GMT 2006org.hibernate.util

JDBCExceptionReporter

public final class JDBCExceptionReporter extends Object

Fields Summary
public static final Log
log
public static final String
DEFAULT_EXCEPTION_MSG
public static final String
DEFAULT_WARNING_MSG
Constructors Summary
private JDBCExceptionReporter()


	  
Methods Summary
public static voidlogAndClearWarnings(java.sql.Connection connection)

		if ( log.isWarnEnabled() ) {
			try {
				logWarnings( connection.getWarnings() );
			}
			catch (SQLException sqle) {
				//workaround for WebLogic
				log.debug("could not log warnings", sqle);
			}
		}
		try {
			//Sybase fail if we don't do that, sigh...
			connection.clearWarnings();
		}
		catch (SQLException sqle) {
			log.debug("could not clear warnings", sqle);
		}
	
public static voidlogExceptions(java.sql.SQLException ex)

		logExceptions(ex, null);
	
public static voidlogExceptions(java.sql.SQLException ex, java.lang.String message)

		if ( log.isErrorEnabled() ) {
			if ( log.isDebugEnabled() ) {
				message = StringHelper.isNotEmpty(message) ? message : DEFAULT_EXCEPTION_MSG;
				log.debug( message, ex );
			}
			while (ex != null) {
				StringBuffer buf = new StringBuffer(30)
						.append( "SQL Error: " )
				        .append( ex.getErrorCode() )
				        .append( ", SQLState: " )
				        .append( ex.getSQLState() );
				log.warn( buf.toString() );
				log.error( ex.getMessage() );
				ex = ex.getNextException();
			}
		}
	
public static voidlogWarnings(java.sql.SQLWarning warning)

		logWarnings(warning, null);
	
public static voidlogWarnings(java.sql.SQLWarning warning, java.lang.String message)

		if ( log.isWarnEnabled() ) {
			if ( log.isDebugEnabled() && warning != null ) {
				message = StringHelper.isNotEmpty(message) ? message : DEFAULT_WARNING_MSG;
				log.debug( message, warning );
			}
			while (warning != null) {
				StringBuffer buf = new StringBuffer(30)
				        .append( "SQL Warning: ")
						.append( warning.getErrorCode() )
						.append( ", SQLState: ")
						.append( warning.getSQLState() );
				log.warn( buf.toString() );
				log.warn( warning.getMessage() );
				warning = warning.getNextWarning();
			}
		}