两个 Web 应用程序指向 Sun glassfish 服务器中的相同 jndi
如果两个 Web 应用程序将同一个 jndi 指向 sun glassfish 服务器中的同一个连接池,是否会出现任何问题?或者我是否需要设置不同的jndi来连接到同一个连接池?
另外,对于共享同一个连接池的两个Web应用程序,有什么需要注意的问题吗?例如,是否会有一些事务锁定会导致卡住线程等?
Are there any issues if two web applications is pointing to the same jndi to the same connection pool in sun glassfish server? Or do I need to sctualy setup different jndi to connect to the same connection pool?
Also for two web applications sharing the same connection pool, are there any issues that I need to take note of? E.g will there be some transaction locking which will cause sticks thread etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
连接池中打开的连接不会在所有其他请求/线程之间共享,除非您显式关闭连接。所以绝对不应该有交易问题。仅当连接打开时间超过必要时间或将其传递到打开连接的方法块之外时,才可能遇到问题。只要您遵循在
try-finally
块中尽可能短的范围内打开和关闭连接(以及语句和结果集)的标准 JDBC 习惯用法,就不会有问题。在不同的 Web 应用程序之间共享同一个容器管理的连接池是完全可以的。您只需确保有足够的连接可供多个 Web 应用程序使用。例如,您可能想稍微增加池大小。
An open connection from a connection pool won't be shared among all other requests/threads until you explicitly close the connection. So there should be absolutely no transactional issues. You'll only potentially run into problems when you keep the connection open longer than necessary or pass it around outside the method block where it is been opened. As long as you adhere the standard JDBC idiom of opening and closing the connection (and statement and resultset) in the shortest possible scope in a
try-finally
block, there should be no issues.It's perfectly fine to share the same container managed connection pool among different web applications. You should only ensure that there are enough connections available for use by multiple web applications. You may want to increase the pool size a bit, for example.