In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to configure the Tomcat5+MySQL JDBC connection pool. I hope you will get something after reading this article. Let's discuss it together.
1. Install Tomcat
The * * step of JDBC connection pooling configuration is to download and install Tomcat. Refer to the Tomcat for window installation wizard, basically directly install, note: installation will prompt for an administrative user name and password, this is the user name and password that will be used later, keep in mind.
2. Install MySql
Install it by default.
3. Use Web of Tomcat to manage application configuration data source
Start the Tomcat server, open the browser, enter http://localhost:8080/admin/ (where localhost may be the IP of a machine or the server name), and enter the login page of the management interface. At this time, please enter the user name and password required for the original installation, and log in to the management interface.
Select Resources-Data sources to enter the JDBC connection pool configuration data source interface, select Data Source Actions-> select Create New Data Source, and enter the configuration details interface, as shown below:
JNDI Name: jdbc/mysql Data Source URL: jdbc:mysql://192.168.0.16/SUBRDB JDBC Driver Class: org.gjt.mm.mysql.Driver User Name: root Password: * Max. Active Connections: 4 Max. Idle Connections: 2 Max. Wait for Connection: 500 Validation Query:
Request to enter JNDI Name and other information, in addition to JDBC DriverClass, the rest can be filled in according to your needs. For example, the content of Data Source URL may be: jdbc:mysql:// IP or name / DataBaseName, where DataBaseName is your database name, and IP is the IP or name of the server where your database is located. * * Click Save- > Commit Change. In this way, the basic data of your data source is half configured.
4. Modify the configuration file corresponding to your reference under web.xml and% TOMCAT_HOME%\ conf\ Catalina\ localhost
Navigate to% TOMCAT_HOME%\ conf through the folder, open web.xml, and add the following before:
DB Connection jdbc/mysql javax.sql.DataSource Container
Note that the content filled in by res-ref-name should be the same as the JNDI Name name mentioned above.
Navigate to% TOMCAT_HOME%\ conf\ Catalina\ localhost through the folder, find the .xml file corresponding to your web application, such as ROOT.xml, and add code under this file:
At this point, the configuration is almost complete.
5. Other points for attention
When we configure the JDBC connection pool configuration, don't forget that the JDBC driver mysql-connector-java-3.0.9-stable-bin.jar must be placed in the corresponding directory of Tomcat. Your JDBC driver may be higher than the author, but as long as it corresponds to the MySql used, because I found that the lower version of the JDBC driver can not support version 4.0.* MySQL database. It is recommended to place it under% TOMCAT_HOME%\ common\ lib and WEB-INF\ lib of the application. What's the difference between the two? In fact, it is clear at a glance that common\ li is a library file location that can be used by all applications.
Restart your Tomcat service.
6. Write test code
Create a Test.jsp file in the application directory with the following code:
Running result:
My test starts at 12345678 and my test ends because my rs.getString (1) is stored in the database for 12345678.
After reading this article, I believe you have some understanding of "how to configure Tomcat5+MySQL JDBC connection pool". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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.