If you just interested in mysql, you can use this short message. If you want to configure the connection pool of other database types, you can also use simple modification parameters. 1. Install the Tomcat for Window's installation wizard, basically directly installed, Note: Enter the management username and password when installing, this is the username and password that will be used later, remember. 2, install MySQL default installation. 3, use Tomcat's Web Management App to Configure the data source to start the Tomcat server, open the browser, enter http: // localhost: 8080 / admin / (where localhost may be a machine's IP or server name), enter the management interface Log in page, at this time, please enter the username and password required to enter the original installation, log in to the management interface, select Resources-Data Sources to enter the configuration data source interface, select Data Source Actions -> Select CREATE New Data Source, enter the configuration details interface The content is as follows:
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:
The information requested by JNDI Name is required, in which other other can be filled in according to your needs. For example, the content of the Data Source URL may be: jdbc: mysql: // ip or name / databasename, where DatabaseName is your database name, IP is the IP or name of the server where your database is located. Finally click Save-> Commit Change. So your basic data of your data source is half configured. 4, web.xml and% tomcat_home% / conf / catalina / localhost, corresponding to your reference configuration file modification to navigate through the folder to% tomcat_home / conf, open web.xml, add it in front of web-app> The following:
6. Writing test code builds a test.jsp file in the application's directory, the code is as follows: <% @ page import =" java.sql. * "%> <% @ Page import =" javax.sql. * "%> <% @ Page import =" javax .naming. * "%> <% @ Page session =" false "%>
head> body> body> body> body> body> body> body> > html> Run results: My test starts 12345678 My test ends because my RS.Getstring (1) is stored in the database 123456787. Summary the configuration process and its simply clear, these configurations are exempt from the past developers to write the data source connection pool, which is also a strong support for the development process.