FileDocCategorySizeDatePackage
JDBCExceptionHelper.javaAPI DocHibernate 3.2.53097Mon Mar 06 08:16:28 GMT 2006org.hibernate.exception

JDBCExceptionHelper

public final class JDBCExceptionHelper extends Object
Implementation of JDBCExceptionHelper.
author
Steve Ebersole

Fields Summary
Constructors Summary
private JDBCExceptionHelper()

	
Methods Summary
public static org.hibernate.JDBCExceptionconvert(SQLExceptionConverter converter, java.sql.SQLException sqlException, java.lang.String message)
Converts the given SQLException into Hibernate's JDBCException hierarchy, as well as performing appropriate logging.

param
converter The converter to use.
param
sqlException The exception to convert.
param
message An optional error message.
return
The converted JDBCException.

		return convert( converter, sqlException, message, "???" );
	
public static org.hibernate.JDBCExceptionconvert(SQLExceptionConverter converter, java.sql.SQLException sqlException, java.lang.String message, java.lang.String sql)
Converts the given SQLException into Hibernate's JDBCException hierarchy, as well as performing appropriate logging.

param
converter The converter to use.
param
sqlException The exception to convert.
param
message An optional error message.
return
The converted JDBCException.

		JDBCExceptionReporter.logExceptions( sqlException, message + " [" + sql + "]" );
		return converter.convert( sqlException, message, sql );
	
public static java.lang.StringdetermineSqlStateClassCode(java.lang.String sqlState)

		if ( sqlState == null || sqlState.length() < 2 ) {
			return sqlState;
		}
		return sqlState.substring( 0, 2 );
	
public static intextractErrorCode(java.sql.SQLException sqlException)
For the given SQLException, locates the vendor-specific error code.

param
sqlException The exception from which to extract the SQLState
return
The error code.

		int errorCode = sqlException.getErrorCode();
		SQLException nested = sqlException.getNextException();
		while ( errorCode == 0 && nested != null ) {
			errorCode = nested.getErrorCode();
			nested = nested.getNextException();
		}
		return errorCode;
	
public static java.lang.StringextractSqlState(java.sql.SQLException sqlException)
For the given SQLException, locates the X/Open-compliant SQLState.

param
sqlException The exception from which to extract the SQLState
return
The SQLState code, or null.

		String sqlState = sqlException.getSQLState();
		SQLException nested = sqlException.getNextException();
		while ( sqlState == null && nested != null ) {
			sqlState = nested.getSQLState();
			nested = nested.getNextException();
		}
		return sqlState;
	
public static java.lang.StringextractSqlStateClassCode(java.sql.SQLException sqlException)
For the given SQLException, locates the X/Open-compliant SQLState's class code.

param
sqlException The exception from which to extract the SQLState class code
return
The SQLState class code, or null.

		return determineSqlStateClassCode( extractSqlState( sqlException ) );