← Back to Stormify Documentation

acquirePreparedStatement

Acquires a prepared statement for sql, reusing one from the connection's internal cache if available. The returned statement reports close() as a "release" — the underlying handle is reset and returned to the cache for the next call. Callers must use the standard .use { } pattern; the connection itself owns the real lifetime and physically closes all cached statements on Connection.close.

Use this for cacheable, parameterised statements where the same SQL string is likely to be re-executed (typical CRUD / find / list paths). For statements that need generated-key retrieval or explicit column-name returns, call initStatement directly so they bypass the cache.

The default falls back to initStatement (no caching) for Connection implementations that have not opted into the cache.