type

SqlConnPool

src const class SqlConnPool : Obj

SqlConnPool manages a pool of reusable SQL connections

constructors

make

It-block construtor

fields

linger

Time to linger an idle connection before closing it.

log

Logger

maxConns

Max number of simultaneous connections to allow before blocking threads

password

Connection password

timeout

Max time to block waiting for a connection before raising TimeoutErr

uri

Connection URI

username

Connection username

methods

checkLinger

Close idle connections that have lingered past the linger timeout.

close

Close all connections 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.

Slot Details

checkLinger

src Void checkLinger()

Close idle connections that have lingered past the linger timeout.

close

src Void close()

Close all connections and raise exception on any new executes

execute

src Void execute(|SqlConn| f)

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

isClosed

src Bool isClosed()

Return if close has been called.

linger

src const Duration linger := 5min

Time to linger an idle connection before closing it. An external actor must call checkLinger periodically to close idle connetions.

log

src const Log log := Log.get("sqlPool")

Logger

make

src new make(|This|? f)

It-block construtor

maxConns

src const Int maxConns := 10

Max number of simultaneous connections to allow before blocking threads

onClose

src protected virtual Void onClose(SqlConn c)

onClose is invoked just before a connection is closed by the pool. This method can be used to clean up any state owned by the connection, for example by closing prepared Statements that are stored in the connection's stash.

onOpen

src protected virtual Void onOpen(SqlConn c)

onOpen is invoked just after a connection is opened by the pool. This method can be used to modify the newly opened connection, for example by turning off autoCommit.

password

src const Str? password

Connection password

timeout

src const Duration timeout := 30sec

Max time to block waiting for a connection before raising TimeoutErr

uri

src const Str uri

Connection URI

username

src const Str? username

Connection username