Package org.hibernate
Class JDBCException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ConstraintViolationException,DataException,GenericJDBCException,JDBCConnectionException,LockAcquisitionException,PessimisticLockException,QueryTimeoutException,SQLGrammarException
public class JDBCException extends HibernateException
Wraps aSQLExceptionarising from the JDBC driver. Indicates that an error occurred during a JDBC call.- See Also:
SQLException, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JDBCException(String message, SQLException cause)Constructs aJDBCExceptionusing the given information.JDBCException(String message, SQLException cause, String sql)Constructs aJDBCExceptionusing the given information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetErrorCode()Get the vendor specific error code from the underlyingSQLException.StringgetErrorMessage()StringgetSQL()Get the actual SQL statement being executed when the exception occurred.SQLExceptiongetSQLException()Get the underlyingSQLException.StringgetSQLState()Get the X/Open or ANSI SQL SQLState error code from the underlyingSQLException.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
JDBCException
public JDBCException(String message, SQLException cause)
Constructs aJDBCExceptionusing the given information.- Parameters:
message- The message explaining the exception conditioncause- The underlying cause
-
JDBCException
public JDBCException(String message, SQLException cause, String sql)
Constructs aJDBCExceptionusing the given information.- Parameters:
message- The message explaining the exception conditioncause- The underlying causesql- The sql being executed when the exception occurred
-
-
Method Detail
-
getSQLState
public String getSQLState()
Get the X/Open or ANSI SQL SQLState error code from the underlyingSQLException.- Returns:
- The X/Open or ANSI SQL SQLState error code; may return null.
- See Also:
SQLException.getSQLState()
-
getErrorCode
public int getErrorCode()
Get the vendor specific error code from the underlyingSQLException.- Returns:
- The vendor specific error code
- See Also:
SQLException.getErrorCode()
-
getSQLException
public SQLException getSQLException()
Get the underlyingSQLException.- Returns:
- The SQLException
-
getSQL
public String getSQL()
Get the actual SQL statement being executed when the exception occurred.- Returns:
- The SQL statement; may return null.
-
getErrorMessage
public String getErrorMessage()
- Returns:
- The error message without the SQL statement appended
-
-