java.lang.Object
java.lang.Throwable
java.lang.Exception
is.codion.common.db.exception.DatabaseException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AuthenticationException
,DeleteException
,MultipleRecordsFoundException
,QueryTimeoutException
,RecordNotFoundException
,ReferentialIntegrityException
,UniqueConstraintException
,UpdateException
An exception coming from a database-layer.
- See Also:
-
Constructor Summary
ConstructorDescriptionDatabaseException
(String message) Constructs a new DatabaseException instanceDatabaseException
(String message, String statement) Constructs a new DatabaseException instanceDatabaseException
(SQLException cause) Constructs a new DatabaseException instanceDatabaseException
(SQLException cause, String message) Constructs a new DatabaseException instanceDatabaseException
(SQLException cause, String message, String statement) Constructs a new DatabaseException instance -
Method Summary
Modifier and TypeMethodDescriptionfinal int
Returns the underlying error code, note that this is only available when running with a local database connection.final void
setStackTrace
(StackTraceElement[] stackTrace) sqlState()
Returns the underlying sql state, note that this is only available when running with a local database connection.Returns the sql statement causing this exception, if available, note that this is only available when running with a local database connection.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, toString
-
Constructor Details
-
DatabaseException
Constructs a new DatabaseException instance- Parameters:
message
- the exception message
-
DatabaseException
Constructs a new DatabaseException instance- Parameters:
message
- the exception messagestatement
- the sql statement which caused the exception
-
DatabaseException
Constructs a new DatabaseException instance- Parameters:
cause
- the root cause, the stack trace is copied and used
-
DatabaseException
Constructs a new DatabaseException instance- Parameters:
cause
- the root cause, the stack trace is copied and usedmessage
- the exception message
-
DatabaseException
Constructs a new DatabaseException instance- Parameters:
cause
- the root cause, the stack trace is copied and usedmessage
- the exception messagestatement
- the sql statement which caused the exception
-
-
Method Details
-
statement
Returns the sql statement causing this exception, if available, note that this is only available when running with a local database connection.- Returns:
- the sql statement which caused the exception, an empty Optional if not avialable
-
errorCode
public final int errorCode()Returns the underlying error code, note that this is only available when running with a local database connection.- Returns:
- the underlying error code, -1 if not available
-
sqlState
Returns the underlying sql state, note that this is only available when running with a local database connection.- Returns:
- the underlying sql state, an empty Optional if not available
-
setStackTrace
- Overrides:
setStackTrace
in classThrowable
-