Database Connection Pooling
I need to implement a simple connection pooling mechanism for my application.
The problem is I have almost no knowledge working with database connections.
What things should I take into account? Is there any lightweight library out there?
I expect the code to open as few connections as possible.
13 Replies
⌛
This post has been reserved for your question.
Hey @Defective! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Here is my current approach:
What can I improve here? Is the code even remotely "okay"?
Just use HikariCP
thats the one to use
GitHub
GitHub - brettwooldridge/HikariCP: 光 HikariCP・A solid, high-perform...
光 HikariCP・A solid, high-performance, JDBC connection pool at last. - GitHub - brettwooldridge/HikariCP: 光 HikariCP・A solid, high-performance, JDBC connection pool at last.
as to your code - it is not thread safe
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
if you have multiple threads taking and releasing connections (which is what connection pools are for) you will have issues
Thank you, I will check it out. I hope it is "lightweight" in that it takes least amount of space possible in the finished application

that good enough?
Yeah, but I don't want to keep more connections open than needed at the given time
Yes, looks nice. I will try it out
Perfect! That's exactly what I was looking for, thank you!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@1014466568484294656>.