Does the ConnectionPool from SqlJocky require a close Does the ConnectionPool from SqlJocky require a close dart dart

Does the ConnectionPool from SqlJocky require a close


This doesn't fully answer your question but I think you could simplify your code like:

Future<List<T>> getAll() async {  try {    var result = await connectionPool.query(        "SELECT id, name, description FROM role");    return this._processRows(await result.toList());  } catch(error) {    // TODO: Better error handling.    print(error);    return null;  } }

I'm sure here is no need to close a connection with query. I don't know about prepareExecute though.
According to a comment in the SqlJocky code it can take quite some time for a connection to be released by the database server.
Maybe you need to increase the connection pool size (default 5) so you don't run out of connections while ConnectionPool is waiting for connections to be released.


After some feedback from Heroku I managed to resolve this problem by implementing a timer task that does every 50 seconds a basic MySQL call.

The response from Heroku:

Heroku's networking enforces an idle timeout of 60-90 seconds to prevent runaway processes. If you're using persistent connections in your application, make sure that you're sending a keep-alive at, say, 55 seconds to prevent your open connection from being dropped by the server.

The work around code:

const duration = const Duration(seconds: 50);new Timer.periodic(duration, (Timer t) {  // Do a simple MySQL call with on the connection pool.  this.connectionPool.execute('SELECT id from role');  print('*** Keep alive triggered for MySQL heroku ***');});