1、Tomcat下数据源配置。在conf下新建catalina文件下,再在catalina下新建localhost文件夹。最后在localhost下新建hr.xml,hr.xml内容如下所示(连接的为oracle数据库)。在lib文件夹下放入oracle9ijdbc.jar包。
<Context path="/hr" docBase="E:\workspace\Manager_jh\WebRoot"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/oads" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="hr" password="hr"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@192.168.10.3:1521:miaerp"/>
</Context>
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/oads" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="hr" password="hr"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@192.168.10.3:1521:miaerp"/>
</Context>
2、web.xml配置。在web.xml中配置如下信息,指向数据源。
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<resource-ref>
<description>oa datasource</description>
<res-ref-name>jdbc/oads</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<description>oa datasource</description>
<res-ref-name>jdbc/oads</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
转载于:https://blog.51cto.com/lwyhnbc/240616