使用的wamp集成的php项目,读取某些数据用到了tomcat,现在把数据库和web端分离。数据库使用阿里云服务器
在Tomcat 8.5\conf下的 context.xml 中添加如下代码,即可指定数据库访问
<Context>
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource
auth="Container"
name="jdbc/report"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
username="gzygxy" (数据库用户名)
password="***" (数据库密码)
url="jdbc:mysql://(数据库ip):3306/met_nj?characterEncoding=utf8"
/>
</Context>