数据库连接和会话一样吗?
我对
- 数据库打开会话
- 连接池
之间的关系有点困惑。为了详细说明,我将 JDBC 与 Oracle 9i DB 结合使用,并且还使用连接池来池连接。
我想知道的是:当我的连接在池中空闲时,它们是否与数据库的任何Open Session
相关联?那么,如果我有 5 个连接在池中闲置,这是否意味着将有 5 个对应的活动会话与我的数据库打开?
I'm bit confused about relationship between a
- Database Open Session
- Connection pooling
To elaborate, I'm using JDBC with Oracle 9i DB and I'm also using a Connection Pool to pool my connections.
What I would like to know is that: When my connections are lying idle in pool, are they associated with any Open Session
with database? So If I've 5 connection sitting idle in pool, does that mean there will be 5 corresponding active session Open with my database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的..我从其他论坛得到了一些答案:
这完全取决于池的实现。它们看起来可能与一个打开的会话关联一段时间,然后如果一段时间内不使用连接,会话就会关闭,并在再次需要时重新建立。
在一段时间内不保持它们打开意味着在请求快速到来时浪费建立连接的开销。让它们永远开放会无缘无故地占用有限的资源。这两者都违背了我对连接池的理解。
Ok.. I got some answer from other forums:
That depends entirely on the pool implementation. It seems likely they are associated with an open session for a while, and then the sessions are closed if the connections are not used for some time, and reestablished when they're needed again.
Not keeping them open for some amount of time would mean wasting the overhead of establishing connections when requests are coming in rapid-fire. Keeping them open forever would hog limited resources for no good reason. Both of these go against my understanding of the very point of having a connection pool in the first place.