JDBC 连接池
我通过扩展连接和驱动程序类编写了连接池。它工作正常,但问题是我现在想施加一个上限,如果达到上限,那么我想将请求存储在队列中,并在任何连接空闲时返回。我该怎么办呢。 预先感谢您的回复
I have wriiten my connection pooling by extending connection and driver class. It is working fine but the problem is I want to now impose a upper limit and if te upper limit is reached then I want to store the request in the queue and return when any connections are free. How can I do this.
Thanks in advance for replys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个非常糟糕的设计。
您的池不应该要求您扩展任何内容。它也不应该关心请求。只需检查进出连接即可。让另一个组件管理请求队列并与您的池协作以获取连接。
连接池已经做好了。最容易维护的一个是由其他人编写的。
This is a bad, bad design.
Your pool should not require you to extend anything. It should not be concerned with requests, either. Just check connections in and out. Have another component manage a queue of requests and collaborate with your pool to get connections.
Connection pools have been done. The easiest one to maintain is the one that's written by someone else.