1.在web.xml中添加:
<resource-ref>
<res-ref-name>jdbc/MTSDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
2.在tomcat的context.xml中配置数据源:
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" maxActive="20" maxIdel="10" maxWait="1000" name="jdbc/MTSDB" password="passw0rd" type="javax.sql.DataSource" url="jdbc:mysql://10.19.220.36:3306/mobdb?autoReconnect=true&characterEncoding=utf8&useUnicode=true&generateSimpleParameterMetadata=true" username="mobuser" />3.在property配置文件中添加变量
mcsJNDI=java:comp/env/jdbc/MTSDB