tomcat配置jndi连接数据库(druid连接池)
1、将驱动包复制到tomcat安装目录下的lib文件夹
druid-1.1.9.jar
log4j-1.2.17.jar
2、在tomcat安装目录下conf/context.xml文件加入一个Resource
<Resource name="vtas"
factory="com.alibaba.druid.pool.DruidDataSourceFactory"
auth="Container"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@//txn-cluster:1521/shqhtxn"
driverClassName ="oracle.jdbc.driver.OracleDriver"
username="abc"
password="123456"
initialSize = "30"
maxActive="200"
minIdle="30"
maxWait="-1"
testOnBorrow="true"
validationQuery="select 1 from dual"
connectionProperties = "config.decrypt=false" filters= "config,stat,wall"
/>
3、spring的数据源配置
<!-- PRD环境 -->
<beans profile="prd">
<context:property-placeholder ignore-unresolvable="true" location="classpath:/env/configurations-prd.properties" />
<!-- 数据源配置,使用应用服务器的数据库连接池 -->
<jee:jndi-lookup id="dataSource" jndi-name="${jndi.name}" />
</beans>
参考资料:
https://www.cnblogs.com/wuyanshun/p/6763162.html
来源:CSDN
作者:csj50
链接:https://blog.csdn.net/csj50/article/details/104738253