ensureConnected method

Future<void> ensureConnected()

If the client does not yet have any open connections in its pool, attempts to open a connection, else returns immediately.

Since the client lazily creates new connections as needed (up to the configured concurrency limit), the first connection attempt will usually only happen when the first query is run on a client. The ensureConnected() method allows you to explicitly check that the client can connect to the database without running a query (can be useful to catch any errors resulting from connection mis-configuration).

Implementation

Future<void> ensureConnected() {
  return _pool.ensureConnected();
}