MySQLConnectionPool class

Class to create and manage pool of database connections

Constructors

MySQLConnectionPool({required dynamic host, required int port, required String userName, required dynamic password, required int maxConnections, String? databaseName, bool secure = true, String collation = 'utf8_general_ci', int timeoutMs = 10000, SecurityContext? securityContext, bool onBadCertificate(X509Certificate certificate)?, Duration idleTestThreshold = const Duration(minutes: 1), Duration maxConnectionAge = const Duration(hours: 12), Duration maxSessionUse = const Duration(hours: 8), int maxErrorCount = 64, String? timeZone, FutureOr<void> onConnectionOpen(MySQLConnection conn)?, MySQLPoolRetryOptions retryOptions = const MySQLPoolRetryOptions()})
Creates new pool

Properties

activeConnectionsQty int
Number of active connections in this pool Active are connections which are currently interacting with the database
no setter
allConnectionsQty int
Active + Idle connections
no setter
collation String
final
databaseName String?
final
hashCode int
The hash code for this object.
no setterinherited
host → dynamic
final
idleConnectionsQty int
Number of idle connections in this pool Idle are connections which are currently not interacting with the database and ready to be used
no setter
idleTestThreshold Duration
final
maxConnectionAge Duration
final
maxConnections int
final
maxErrorCount int
final
maxSessionUse Duration
final
onBadCertificate bool Function(X509Certificate certificate)?
final
onConnectionOpen FutureOr<void> Function(MySQLConnection conn)?
final
port int
final
retryOptions MySQLPoolRetryOptions
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secure bool
final
securityContext SecurityContext?
final
timeoutMs int
final
timeZone String?
final
userName String
final

Methods

close() Future<void>
Closes all connections in this pool and frees resources
execute(String query, [Map<String, dynamic>? params, bool iterable = false]) Future<IResultSet>
See MySQLConnection.execute
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prepare(String query, [bool iterable = false]) Future<PreparedStmt>
See MySQLConnection.prepare
status() MySQLPoolStatus
toString() String
A string representation of this object.
inherited
transactional<T>(FutureOr<T> callback(MySQLConnection conn)) Future<T>
See MySQLConnection.transactional
withConnection<T>(FutureOr<T> callback(MySQLConnection conn)) FutureOr<T>
Get free connection from this pool (possibly new connection) and invoke callback function with this connection

Operators

operator ==(Object other) bool
The equality operator.
inherited