Closed HannesRammer closed 10 years ago
pool.close(); is the correct way to close them.
And you should close them after your done with them so that they do not count against your maximum concurrent connection limit.
I don't know why you'd want multiple pools — the whole idea of having a connection pool is that there's a bunch of connections waiting to be used. As a result, you spend less time connecting to the server, and if you use prepared queries more than once then the queries don't have to be prepared multiple times. SQLJocky will queue queries if there isn't a free connection at the time, and will execute the query as soon as a connection becomes available.
Regarding pool.close():
Calling pool.close() is a bad idea at the moment, as it calls socket.close() on all currently open connections. You should only call it if you know that there are no ongoing operations.
I need to do some thinking about how to manage the pool connections. It would probably be a good thing to be able to close any currently unused connections if you needed to for some reason, and it would possibly also be nice to be able to change the pool size while it is in use. It would be good if it could tell you how many connections were currently open and in use.
I didnt get the part with not having to prepare queries multiple times..
So would you say I could keep a single active pool during the entire runtime of my app!?
and is there a maximum for max connections?
You should be able to keep a connection open. The maximum number of connections is probably set in the mysql server's config.
:+1:
Hey :)
I develop the Dartabase tools Model https://github.com/HannesRammer/Dartabase/tree/master/dartabase_model and Migration https://github.com/HannesRammer/Dartabase/tree/master/dartabase_migration using your package.
I have multiple connection pools running at the same time,basically I am creating a pool each time I call the db.
Is there a way to close a single pool after the query is done? or is my approach not the right one
1.multiple pools? yes or no
on yes 1.1.should we close pools?
I was thinking, I should create a pool only when someone hits save/load. but then I cant close them, and then i am thinking .. after running a few minutes there must be like x many pools running?
on no 1.2.should we only keep only one pool for the dart server while the program is executed? and everyone would have to query via this single pool!?
would we then still have to close the pool at the end of the connection and what if with one pool the max connections are reached?