Class DatabaseException
- All Implemented Interfaces:
Serializable
Database.
If the cause of this exception is a SQLException, the getErrorCode() and getSqlState()
accessors are shorthand for retrieving the corresponding SQLException values.
- Since:
- 1.0.0
- Author:
- Mark Allen
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDatabaseException(@Nullable String message) Creates aDatabaseExceptionwith the givenmessage.DatabaseException(@Nullable String message, @Nullable Throwable cause) Creates aDatabaseExceptionwhich wraps the givencause.DatabaseException(@Nullable Throwable cause) Creates aDatabaseExceptionwhich wraps the givencause. -
Method Summary
Modifier and TypeMethodDescriptionShorthand forSQLException.getErrorCode()if this exception was caused by aSQLException.getFile()getHint()getLine()Shorthand forSQLException.getSQLState()if this exception was caused by aSQLException.getTable()getWhere()Determines if this exception is recognized as a deadlock.Determines if this exception is recognized as a foreign-key violation.Determines if this exception is recognized as a serialization failure.Determines if this exception is recognized as a timeout or cancellation.Determines if this exception is recognized as transient.Determines if this exception is recognized as a unique constraint violation.toString()Renders general diagnostics without automatically appending server detail, hint, internal query or context.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
DatabaseException
Creates aDatabaseExceptionwith the givenmessage.- Parameters:
message- a message describing this exception
-
DatabaseException
Creates aDatabaseExceptionwhich wraps the givencause.- Parameters:
cause- the cause of this exception
-
DatabaseException
Creates aDatabaseExceptionwhich wraps the givencause.- Parameters:
message- a message describing this exceptioncause- the cause of this exception
-
-
Method Details
-
toString
Renders general diagnostics without automatically appending server detail, hint, internal query or context. Explicit diagnostic accessors retain those fields; messages and original causes can still contain data. -
getErrorCode
Shorthand forSQLException.getErrorCode()if this exception was caused by aSQLException.- Returns:
- the value of
SQLException.getErrorCode(), or empty if not available
-
getSqlState
Shorthand forSQLException.getSQLState()if this exception was caused by aSQLException. The available operational code is preserved verbatim; secure-parameter literal scrubbing does not modify it.- Returns:
- the value of
SQLException.getSQLState(), or empty if not available
-
isUniqueConstraintViolation
Determines if this exception is recognized as a unique constraint violation.This method is intentionally conservative: it returns
trueonly when Pyranid recognizes a database-specific error code or SQLState as a unique or primary-key uniqueness violation.- Returns:
trueif this exception is recognized as a unique constraint violation- Since:
- 4.3.0
-
isForeignKeyViolation
Determines if this exception is recognized as a foreign-key violation.This method is intentionally conservative: it returns
trueonly when Pyranid recognizes a database-specific error code or SQLState as a foreign-key violation. For example, SQL Server error547is not classified as a foreign-key violation by code alone because the same error code also covers other constraint failures, such asCHECKconstraints.- Returns:
trueif this exception is recognized as a foreign-key violation- Since:
- 4.3.0
-
isDeadlock
Determines if this exception is recognized as a deadlock.This method is intentionally conservative: it returns
trueonly when Pyranid recognizes a database-specific error code or SQLState as a deadlock.- Returns:
trueif this exception is recognized as a deadlock- Since:
- 4.3.0
-
isTransient
Determines if this exception is recognized as transient.This method is intentionally conservative: it returns
truefor JDBC transient/recoverable exception classes, SQLState classes for connection exceptions and transaction rollbacks, or database-specific deadlock/lock-timeout signals recognized by Pyranid. Atrueresult does not guarantee that retrying the operation will succeed.- Returns:
trueif this exception is recognized as transient- Since:
- 4.3.0
-
isSerializationFailure
Determines if this exception is recognized as a serialization failure.This method is intentionally conservative: it returns
trueonly when Pyranid recognizes a database-specific error code or SQLState as a serialization failure.- Returns:
trueif this exception is recognized as a serialization failure- Since:
- 4.4.0
-
isTimeout
Determines if this exception is recognized as a timeout or cancellation.This method is intentionally conservative: it returns
trueonly when Pyranid recognizes a JDBC timeout, database-specific timeout, or database-specific cancellation signal. Atrueresult does not mean the operation is automatically safe to retry.- Returns:
trueif this exception is recognized as a timeout or cancellation- Since:
- 4.4.0
-
getColumn
-
getConstraint
- Returns:
- the value of the offending
constraint, or empty if not available - Since:
- 1.0.12
-
getDatatype
- Returns:
- the value of the offending
datatype, or empty if not available - Since:
- 1.0.12
-
getDetail
-
getFile
-
getHint
-
getInternalPosition
- Returns:
- the positive, one-based character position within the internal query, or empty if the server supplied none
- Since:
- 1.0.12
-
getInternalQuery
- Returns:
- the value of the offending
internalQuery, or empty if not available - Since:
- 1.0.12
-
getLine
-
getDbmsMessage
- Returns:
- the value of the error
dbmsMessage, or empty if not available - Since:
- 1.0.12
-
getPosition
- Returns:
- the positive, one-based character position within the submitted query, or empty if the server supplied none
- Since:
- 1.0.12
-
getRoutine
- Returns:
- the value of the offending
routine, or empty if not available - Since:
- 1.0.12
-
getSchema
-
getSeverity
- Returns:
- the error
severity, or empty if not available - Since:
- 1.0.12
-
getTable
-
getWhere
-