Re: MYSQL 8.0.18 xdev, total connections are keeps increasing
Posted by: Filipe Silva
Date: October 20, 2021 05:04AM


So, when I execute each query, everytime, I create a new Client object from factory and close the client object after the use?

No. You should create one singe instance of the Client object and keep it in the application or session scope (whatever meets your needs). Then, while processing your application requests, you get a Session from this shared Client instance, use it and close it in the end. Finally, on scope destruction, you should call client.close() to release all MySQL connections.

I don't know if this fits your model, but this is how it is usually done. It may happen that you don't even need to use a Client instance at all (consequently no session pooling) and creating Session instances using a SessionFactory is fine.

The rule of thumb is that you must close your Session/Client objects. Not doing so may cause some kind of resource leak.

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.