In fact, A. xml file with the same name as the virtual site is created under tomcat/CONF/Catalina/localhost.
Open this file and you will see all the content
For example:
<? XML version = // '1. 0 // 'encoding=//// // 'utf-8 // '?>
<Context docbase = // "E: /// // webpage // webpg // "Path = ////"/ webpg // "workdir = //" E: /// // webpage // Tomcat // work //// /// webpg // ">
<Resource Name = // "Java: COMP/ENV/jdbc/Webpage //" type = // "javax. SQL. datasource // "/>
<Resourceparams name = // "Java: COMP/ENV/jdbc/Webpage ///">
<Parameter>
<Name> URL </Name>
<Value> JDBC: mysql: // localhost: 3306/webpage? Autocommit = false & useunicode = true & characterencoding = UTF-8 </value>
</Parameter>
<Parameter>
<Name> password </Name>
<Value> KONKA </value>
</Parameter>
<Parameter>
<Name> maxactive </Name>
<Value> 20 </value>
</Parameter>
<Parameter>
<Name> maxwait </Name>
<Value>-1 </value>
</Parameter>
<Parameter>
<Name> driverclassname </Name>
<Value> com. MySQL. JDBC. Driver </value>
</Parameter>
<Parameter>
<Name> username </Name>
<Value> webpage </value>
</Parameter>
<Parameter>
<Name> maxidle </Name>
<Value> 20 </value>
</Parameter>
</Resourceparams>
</Context>
Context indicates that a site is created.
Docbase indicates the directory where the site is located
Path indicates the access path
Workdir indicates the working directory, because JSP will be compiled as a class file during the first run. These compiled programs exist here.
Resource is used to configure the connection pool...
JDBC: mysql: // 192.168.0.249: 3306/test indicates the IP address of the database. 3306 indicates the default port of MySQL and test indicates the database to be connected.
To connect to MySQL, You need to download the JDBC driver of MySQL after installing MySQL, which can be obtained from the official website of MySQL.
Username Password indicates the user name and password used to connect to the database. Enter the password based on the actual situation.
The com. MySQL. JDBC. Driver string in driverclassname can be found in the JDBC driver description file.
Maxactive indicates the maximum number of connection pools.
Maxidle indicates the number of empty closed connections in the connection pool. (I am not sure what it means. Please reply to me if you know it. Thank you)
Maxwait indicates the connection wait time (-1 indicates waiting all the time)
Now, you need to write a program to test it.
Create an index. jsp in the directory of your virtual site. The program content is as follows:
<% @ Page contenttype = // "text/html; charset = GBK //" %>
<% @ Page import = // "javax. Naming. *, java. SQL. *, javax. SQL. * //" %>
<%
Context initcontext = new initialcontext ();
Context envcontext = (context) initcontext. Lookup (// "Java:/COMP/ENV ////");
Datasource DS = (datasource) envcontext. Lookup (// "eway365_mysql ///"); // The Name Of The connection pool.
Connection conn = Ds. getconnection ();
Out. println (// "connection pool configuration successful! ////");
Conn. Close ();
Out. println (// "connection successful! <HR> ////");
%>
Okay. If there is no problem with the execution, it will be done ..........