<?xml version="1.0" encoding="UTF-8"?>
<!? The contents of this file will be loaded for each web application ?>
<context>
<!? Default set of monitored resources 172.16.5.28:KM?>
<watchedresource>WEB-INF/web.xml</watchedresource>
<resource
name="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
maxactive="500"
maxidle="30"
maxwait="10000"
username="test"
password="test
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl">
</resource>
</context>
然後附件中的文件就派上用場了(encrypt2.bat,commons-dbcp-1.2.2.jar和commons-pool-1.4.jar )
1、進入tomcat的安裝目錄: tomcatroot\common\lib
2、複製encrypt2.bat和commons-dbcp-1.2.2.jar和commons-pool-1.4.jar 進入該目錄
3、進入cmd狀態,切換入tomcatroot\common\lib目錄 ,非常重要的是需要把webapps下面的各個應用裏面的重複的jar刪掉也就是要把所有的字母裏面的commons-dbcp*.jar和commons-pool*.jar刪掉
4、輸入encrypt2.bat test (test)還是原密碼,界面上會輸出:
test 加密後: jAVagnSq2eQ=
test 解密後: test
5、修改context.xml password="jAVagnSq2eQ=" 並注意增加一行: factory="org.apache.commons.dbcp.BasicDataSourceFactory"
那麼我們最後的配置就是:
<?xml version="1.0" encoding="UTF-8"?>
<!? The contents of this file will be loaded for each web application ?>
<context>
<!? Default set of monitored resources 172.16.5.28:KM?>
<watchedresource>WEB-INF/web.xml</watchedresource>
<resource
name="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
maxactive="500" maxidle="30"
maxwait="10000"
username="test"
password="jAVagnSq2eQ="
driverClassName="oracle.jdbc.OracleDriver"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
url="jdbc:oracle:thin:@localhost:1521:orcl">
</resource>
</context>