In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about how to use the global database connection pool resources in tomcat/resin. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Tomcat uses JNDI Resource to configure various resources, including database connection pooling. These Resource have two operating scopes, the first is the Context level, that is, the Context-specific Resource, which can only be accessed by the Context to which it belongs, which is obviously not what we want.
The other is to define a globally named resource and then reference it in Context. Here is an example of configuration (server.xml):
Resin is simpler than Tomcat. The configuration of connection pooling in Resin2 is as follows
You can put this configuration in web-app, then the connection pool can only be accessed by the corresponding webapp, then all web-app in host can be accessed, and all webapp in the entire resin can be accessed.
(during the experiment, it was found that there was an error in the document of resin2. If res-ref-name is written as jdbc/dlog, then webapp can never find this resource. Just change it to java:/comp/env/jdbc/dlog.)
Next, we can use the following code in the application to get the DataSource instance of the connection pool
Context initContext = new InitialContext ()
Context envContext = (Context) initContext.lookup ("java:/comp/env")
DataSource ds = (DataSource) envContext.lookup ("jdbc/dlog")
The configuration of other application servers can be configured according to this idea and refer to its manual. It should be said that no matter which way is used, there will not be much difference in performance, how to choose depends on the project structure of your entire server.
The above is how to use the global database connection pool resources in the tomcat/resin shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.