java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSQLException state indicating that a query did not return a result -
Constructor Summary
ConstructorsConstructorDescriptionDatabaseException(@Nullable String message) Constructs a new DatabaseException instanceDatabaseException(@Nullable String message, @Nullable String statement) Constructs a new DatabaseException instanceDatabaseException(@Nullable SQLException cause, @Nullable String message, @Nullable String statement) Constructs a new DatabaseException instanceDatabaseException(SQLException cause) Constructs a new DatabaseException instanceDatabaseException(SQLException cause, @Nullable String message) Constructs a new DatabaseException instance -
Method Summary
Modifier and TypeMethodDescriptionfinal intReturns the underlying error code, note that this is only available when running with a local database connection.final voidsetStackTrace(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
-
Field Details
-
SQL_STATE_NO_DATA
SQLException state indicating that a query did not return a result- See Also:
-
-
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
public DatabaseException(@Nullable SQLException cause, @Nullable String message, @Nullable String statement) 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:
setStackTracein classThrowable
-