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 aSQLException
arising 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 aJDBCException
using the given information.JDBCException(String message, SQLException cause, String sql)
Constructs aJDBCException
using the given information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getErrorCode()
Get the vendor specific error code from the underlyingSQLException
.String
getErrorMessage()
String
getSQL()
Get the actual SQL statement being executed when the exception occurred.SQLException
getSQLException()
Get the underlyingSQLException
.String
getSQLState()
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 aJDBCException
using the given information.- Parameters:
message
- The message explaining the exception conditioncause
- The underlying cause
-
JDBCException
public JDBCException(String message, SQLException cause, String sql)
Constructs aJDBCException
using 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
-
-