class

SqlConnPool

const class SqlConnPool : Obj

SqlConnPool manages a pool of reusable SQL connections

constructors make

It-block construtor

fields autoCommit

autoCommit sets the autoCommit mode used by connections in the pool

checkoutTimeout

Max time to block waiting for a connection to become available in the pool before raising TimeoutErr

connectTimeout

Max time to wait when opening a new connection before raising TimeoutErr, or null to wait as long as the driver allows, which may be forever if the server stalls the handshake

houseKeepingFreq

How often the pool runs houseKeeping

keepAliveFreq

How long an idle connection may sit before houseKeeping pings it, or null to never ping idle connections

leakTrace

Capture a stack trace at every checkout and include it in the leakWarn warning

leakWarn

Time a connection may be held by an execute callback before a warning is logged that it may be stuck or leaked

linger

Time to linger an idle connection before closing it

log

Logger

maxConns

Max number of simultaneous connections to allow before blocking threads

maxLifetime

Max lifetime of a connection before it is retired, regardless of how recently it was used

password

Connection password

queryTimeout

Default timeout applied to every statement created on connections from this pool, or null for no timeout

uri

Connection URI

username

Connection username

validateAfterIdle

Ping a connection on checkout only if it has been idle at least this long, or null to never ping on checkout

validationTimeout

Max time a liveness ping may take before the connection is treated as broken

methods close

Close all connections, stop houseKeeping, and raise exception on any new executes

execute

Allocate a SQL connection inside the given callback

isClosed

Return if close has been called

onClose

onClose is invoked just before a connection is closed by the pool

onOpen

onOpen is invoked just after a connection is opened by the pool

stats

Snapshot of the pool's gauges and cumulative counters

autoCommit Bool : autoCommit

autoCommit sets the autoCommit mode used by connections in the pool. Applied when a connection is opened and restored when it is released, so a callback cannot leave the mode changed for the next borrower. Changing it at runtime takes effect per connection on its next release.

If auto-commit is true then each statement is executed and committed as an individual transaction. Otherwise statements are grouped into transaction which must be closed via SqlConn.commit or SqlConn.rollback.

checkoutTimeout const Duration : checkoutTimeout

Max time to block waiting for a connection to become available in the pool before raising TimeoutErr. Opening a new connection is bounded separately by connectTimeout.

close Void close()

Close all connections, stop houseKeeping, and raise exception on any new executes

connectTimeout const Duration? : connectTimeout

Max time to wait when opening a new connection before raising TimeoutErr, or null to wait as long as the driver allows, which may be forever if the server stalls the handshake. Enforced by the driver via the 'connectTimeout' and 'socketTimeout' connection properties. JDBC resolves it in whole seconds; anything under a second is rounded up to one second.

execute Void execute(|SqlConn| f)

Allocate a SQL connection inside the given callback. If a connection cannot be acquired before checkoutTimeout elapses then a TimeoutErr is raised. Do not close the connection inside the callback.

houseKeepingFreq const Duration : houseKeepingFreq

How often the pool runs houseKeeping: close connections idle past linger, retire connections older than maxLifetime, ping idle connections due a keepAlive, and warn about connections held past leakWarn. Scheduled by the pool; callers do not drive it.

isClosed Bool isClosed()

Return if close has been called.

keepAliveFreq const Duration? : keepAliveFreq

How long an idle connection may sit before houseKeeping pings it, or null to never ping idle connections. A failed ping evicts the connection. Must be less than linger to have any effect. A ping does not count as a use and does not defer linger.

leakTrace const Bool : leakTrace

Capture a stack trace at every checkout and include it in the leakWarn warning. Costs a stack fill per checkout, so it is off by default.

leakWarn const Duration : leakWarn

Time a connection may be held by an execute callback before a warning is logged that it may be stuck or leaked. The warning is logged once per checkout.

linger const Duration : linger

Time to linger an idle connection before closing it.

log const Log : log

Logger

make new make(|This|? f)

It-block construtor

maxConns const Int : maxConns

Max number of simultaneous connections to allow before blocking threads

maxLifetime const Duration : maxLifetime

Max lifetime of a connection before it is retired, regardless of how recently it was used. This protects against database and network infrastructure that kills long lived connections. Connections in use are never retired until released back to the pool.

onClose virtual Void onClose(SqlConn c)

onClose is invoked just before a connection is closed by the pool.

onOpen virtual Void onOpen(SqlConn c)

onOpen is invoked just after a connection is opened by the pool.

password const Str? : password

Connection password

queryTimeout const Duration? : queryTimeout

Default timeout applied to every statement created on connections from this pool, or null for no timeout. Restored when a connection is released, so a callback that changes the connection's timeout cannot leave it changed for the next borrower. Applies per execution, so a batch must complete within it. JDBC resolves it in whole seconds; anything under a second is rounded up to one second.

stats Str:Obj stats()

Snapshot of the pool's gauges and cumulative counters:

  • total: Connections the pool holds, including slots still being opened
  • active: Connections currently checked out. A slot reserved for a connection that is still opening counts here.
  • idle: Connections available for checkout. A connection held by a keepAlive ping counts here.
  • waiting: Threads blocked waiting for a connection
  • maxConns: SqlConnPool.maxConns
  • checkouts: Connections handed to an execute callback
  • checkoutTimeouts: Checkouts that gave up after SqlConnPool.checkoutTimeout
  • opened: Connections opened against the database
  • retired: Connections closed for age: idle past SqlConnPool.linger, or older than SqlConnPool.maxLifetime
  • evicted: Connections closed as broken: failed validation on checkout, failed after an execute callback raised, or failed a keepAlive ping
  • leakWarnings: Warnings logged for connections held past SqlConnPool.leakWarn

uri const Str : uri

Connection URI

username const Str? : username

Connection username

validateAfterIdle const Duration? : validateAfterIdle

Ping a connection on checkout only if it has been idle at least this long, or null to never ping on checkout. The ping costs a database round trip. Governs checkout only: a connection is always validated after an execute callback raises.

validationTimeout const Duration : validationTimeout

Max time a liveness ping may take before the connection is treated as broken. JDBC resolves this in whole seconds; anything under a second is rounded up to one second.

Haxall 4.0.7 ∙ 27-Oct-2026 09:10 EDT