← Back to Stormify Documentation

SQLException

An exception that is thrown when a database error occurs.

This exception is used throughout KDBC and Stormify for all database-related errors:

  • Connection failures

  • Query execution errors

  • Transaction errors

  • Data type conversion errors

  • Constraint violations

It is a RuntimeException and does not need to be caught, though catching it is recommended for proper error handling.

When constructed with a cause produced by an underlying driver, sqlState and errorCode are populated from that driver's vendor-specific fields whenever the platform exposes them (for example, JDBC's java.sql.SQLException). For platforms or drivers that do not surface these values, the properties are null.

Constructors

Link copied to clipboard
constructor(message: String?)

Creates a new SQLException with a message and no driver metadata.

constructor(message: String?, cause: Throwable?)

Creates a new SQLException wrapping an underlying cause. When the cause is a driver exception that carries vendor metadata, sqlState and errorCode are extracted from it automatically.

constructor(message: String?, cause: Throwable?, sqlState: String?, errorCode: Int?)

Creates a new SQLException with explicit driver metadata. Used by KDBC's platform-specific code paths that already know the vendor-reported sqlState and errorCode (e.g. native drivers reading them directly through their C API).

Properties

Link copied to clipboard

The vendor-specific error code reported by the underlying driver, or null if the driver does not provide one or no driver-level cause is attached. The meaning of this value depends on the database vendor (e.g. Oracle ORA codes, MySQL/MariaDB error numbers, PostgreSQL error codes).

Link copied to clipboard

The SQLSTATE code reported by the underlying driver, or null if the driver does not provide one or no driver-level cause is attached. SQLSTATE is a five-character string defined by the SQL standard and used by most relational databases to classify error conditions in a portable way.