在Tomcat 6.0\conf\context.xml中
<?xml version='1.0' encoding='utf-8'?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource
name="jdbc/exam"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
maxIdle="2"
maxWait="5000"
url="jdbc:mysql://localhost:3306/exam?useUnicode=true&characterEncoding=gbk"
username="root"
password="root"
maxActive="20" />
</Context>
---------------------------------------------------------------------------------
& 是& 的转义字符
在xml文件中写成:
url="jdbc:mysql://localhost:3306/exam?useUnicode=true&characterEncoding=gbk"
在java类中写成:
url="jdbc:mysql://localhost:3306/exam?useUnicode=true&characterEncoding=gbk"
本文介绍如何在Tomcat6.0的context.xml文件中配置MySQL数据源,包括设置连接池参数、数据库URL及认证信息等关键步骤。

2159

被折叠的 条评论
为什么被折叠?



