Tomcat下使用Druid配置JNDI数据源且数据库密码加密
程序员文章站
2022-07-13 14:54:33
...
1、生成公钥、私钥及加密密码
java -cp D:\JavaLib\druid\druid-1.1.6.jar com.alibaba.druid.filter.config.ConfigTools appuser
2、添加druid的jar包到【${Tomcat_home}/lib】目录
如:D:\WebServer\tomcat-cdgys\lib\druid-1.1.6.jar
3、在【${Tomcat_home}/conf/server.xml】中增加jndi数据源
4、配置监控结果查看页面
在该文件【${Tomcat_home}/conf/web.xml】中添加以下内容
引用
java -cp D:\JavaLib\druid\druid-1.1.6.jar com.alibaba.druid.filter.config.ConfigTools appuser
2、添加druid的jar包到【${Tomcat_home}/lib】目录
引用
如:D:\WebServer\tomcat-cdgys\lib\druid-1.1.6.jar
3、在【${Tomcat_home}/conf/server.xml】中增加jndi数据源
<Resource name="jdbc/appuserDS" factory="com.alibaba.druid.pool.DruidDataSourceFactory" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@cdgys.db:1521:cdgysorcl" username="appuser" password="fK/JkrUrn12BPy9fIEFu4xHAFsi4OecK2QPWgAls7RuG2k0NK7byESluKxASLRjjfoH1TA3oe5wGJXovG6lykg==" maxActive="50" maxWait="10000" removeabandoned="true" removeabandonedtimeout="60" logabandoned="false" filters="config,stat,wall" useGlobalDataSourceStat="true" validationQuery="SELECT SYSDATE FROM DUAL" connectionProperties="druid.stat.mergeSql=true;druid.stat.slowSqlMillis=2000;config.decrypt=true;config.decrypt.key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIFMABzyEAysv1V/flaVj5G9KelAqzcq7lw9p7NdQkfzIJnJr/qRGADqttXg/RvdXoccV5cFnuZPReB5qfCnGtECAwEAAQ=="/>
4、配置监控结果查看页面
在该文件【${Tomcat_home}/conf/web.xml】中添加以下内容
<servlet> <servlet-name>DruidStatView</servlet-name> <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class> <init-param> <param-name>resetEnable</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>loginUsername</param-name> <param-value>admin</param-value> </init-param> <init-param> <param-name>loginPassword</param-name> <param-value>admin</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>DruidStatView</servlet-name> <url-pattern>/druid/*</url-pattern> </servlet-mapping>
上一篇: tomcat不同版本下websocket的连接数比对
下一篇: 容器,到底是什么东西?