Fix bug with mysql connection

MySQL connection remained opened all time, ending in connection timeout due to the keep alive. Use pools to fix this issue.