tomcat配置数据源

在context.xml文件中添加资源

<Resource name="jdbc/user" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test"
username="root" password="" />

 

在你的项目的web.xml文件中添加对资源的引用

<resource-ref>
<res-ref-name>jdbc/user</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

 

记得把数据库驱动放在tomcat的lib目录下。

你可能感兴趣的:(tomcat)