TransactionStateException

Exception thrown when the statement itself is fine and the transaction it arrived in is not.

The server rejects these before the statement is considered on its own merits, which is why they are not StatementException: nothing about the SQL is wrong, and the server sends no error position to point at. What is wrong is the state around it - a transaction an earlier error already doomed, one declared read-only, one open where the command forbids it, or none open where the command requires one.

25P02 is the one worth naming twice, because it is a consequence rather than a cause: after any error inside an explicit transaction PostgreSQL discards the work and rejects every further command until a ROLLBACK arrives. The failure to read is the first one; this one only says the session never left it.

The two class-25 timeouts, 25P03 and 25P04, are not here - a transaction the server aborted on a timer is ExecutionAbortedException with TRANSACTION_TIMEOUT, alongside the statement timeout it belongs with.

Parameters

sqlState

The SQL state code returned by the database.

serverErrorMessage

The original error message from the database server.

Constructors

Link copied to clipboard
constructor(reason: TransactionStateExceptionReason, sqlState: String, serverErrorMessage: ServerErrorMessage)

Properties

Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard

The primary error message the server raised.

Link copied to clipboard
val hint: String?

Explicit HINT field provided by PostgreSQL.

Link copied to clipboard
open val message: String?
Link copied to clipboard

The context of the query that resulted in this exception, if applicable.

Link copied to clipboard

The transaction state that refused the statement.

Link copied to clipboard

The raw error message received from the database, if applicable.

Link copied to clipboard

The SQL state code associated with the error, if applicable.

Functions

Link copied to clipboard

Finds the Octavius failure behind this throwable, if there is one.

Link copied to clipboard
open override fun getDetailedMessage(): String

Provides a detailed, human-readable description of the error.

Link copied to clipboard
open override fun toString(): String