1.tomcat配置jndi连接池
在 {tomcat目录}\conf\context.xml文件中加入配置,代码如下
<?
xml version="1.0" encoding="UTF-8"
?>
< Context >
< Resource
auth ="Container"
name =" jdbc/mydemoDB "
type ="javax.sql.DataSource"
maxActive="20"
maxIdle="10"
maxWait ="1000"
driverClassName ="oracle.jdbc.driver.OracleDriver"
username ="ccb"
password ="123"
url ="jdbc:oracle:thin:@192.168.41.110:1521:tntdb"
maxActive ="10" />
</ Context >
< Context >
< Resource
auth ="Container"
name =" jdbc/mydemoDB "
type ="javax.sql.DataSource"
maxActive="20"
maxIdle="10"
maxWait ="1000"
driverClassName ="oracle.jdbc.driver.OracleDriver"
username ="ccb"
password ="123"
url ="jdbc:oracle:thin:@192.168.41.110:1521:tntdb"
maxActive ="10" />
</ Context >
2.在web.xml中加入配置
<
resource-ref
>
< description > Database Source </ description >
< res-ref-name > jdbc/mydemoDB </ res-ref-name >
< res-type > javax.sql.DataSource </ res-type >
< res-auth > Container </ res-auth >
</ resource-ref >
< description > Database Source </ description >
< res-ref-name > jdbc/mydemoDB </ res-ref-name >
< res-type > javax.sql.DataSource </ res-type >
< res-auth > Container </ res-auth >
</ resource-ref >
3.把数据库驱动加载到tomcat和应用的lib目录下
4.在birt的Data Source中配置jndi
当配置了具体数据源和JNDI都配置了的时候,首先会去找JNDI配置,如果找不到或者出错,则使用具体数据源配置。
在Eclipse中预览时,JNDI的配置无效,以具体数据源为准。