配置server.xml,在
</Host>
标签前加入
<Context
docBase="C:/eclipse/workspace/myweb/hello"
path="/hello"
reloadable="true"
workDir="C:\eclipse\workspace\myweb\bin">
<Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
driverClassName="com.mysql.jdbc.Driver"
username="root" password="123456"
url="jdbc:mysql://localhost/testmysql"
defaultAutoCommit="true" removeAbondoned="true"
removeAbondonedTimeout="60" logAbondoned="true"/>
</Context>
docBase="C:/eclipse/workspace/myweb/hello"
path="/hello"
reloadable="true"
workDir="C:\eclipse\workspace\myweb\bin">
<Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
driverClassName="com.mysql.jdbc.Driver"
username="root" password="123456"
url="jdbc:mysql://localhost/testmysql"
defaultAutoCommit="true" removeAbondoned="true"
removeAbondonedTimeout="60" logAbondoned="true"/>
</Context>
配置web.xml
<resource-ref>
<res-ref-name>jdb/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<res-ref-name>jdb/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>