在WebRoot下META-INF下添加context.xml 文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<context>
<Resource
name="jdbc/njs"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:compiere"
validationQuery="select * from dual"
username="guo"
password="gyl"
maxWait="50"
maxIdle="2"
maxActive="4" />
</context>
注意:需要把数据库driver拷贝到 应用服务器的 /common/lib 里面;如果是使用eclipse的应用服务器管理功能,需要添加
数据库驱动包到服务器运行环境中。
原来需要在 web.xml 中定义的这部分也可以不要了:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/njs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>