Two web applications pointing to same jndi in sun glassfish server
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 connec开发者_开发问答t 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?
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.
精彩评论