tomcat之JNDI数据源配置

一、docbase包含方式部署项目

D:\apache-tomcat-6.0.29\conf\server.xml里面添加如下内容

 

 <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
			
			<Context debug="9" docBase="D:\Workspaces8.6\testapp\web" path="/" reloadable="true" verbosity="4">
			
			<Resource name="mytest1"
     auth="Container" type="javax.sql.DataSource"
      password="testadmin" 
      driverClassName="oracle.jdbc.driver.OracleDriver" 
      maxIdle="5" maxWait="100" 
      username="testadmin" 
      url="jdbc:oracle:thin:@10.5.43.100:1521:ORCL" 
      maxActive="5" removeAbandoned="true" removeAbandonedTimeout="180" logAbandoned="true"/>

	<Resource name="mytest2"
     auth="Container" type="javax.sql.DataSource"
      password="admin" 
      driverClassName="net.sourceforge.jtds.jdbc.Driver" 
      maxIdle="5" maxWait="100" 
      username="admin" 
      url="jdbc:jtds:sqlserver://10.5.10.66:1433/PMTXX" 
      maxActive="5" removeAbandoned="true" removeAbandonedTimeout="180" logAbandoned="true"/>

			
			</Context> 
      </Host>
 

 

 

 

二、普通部署项目方式

在META-INF文件夹下面创建context.xml,内容如下:

 

 

<Context debug="9" docBase="D:\Workspaces8.6\testapp\web" path="/" reloadable="true" verbosity="4">
			
			<Resource name="mytest1"
     auth="Container" type="javax.sql.DataSource"
      password="testadmin" 
      driverClassName="oracle.jdbc.driver.OracleDriver" 
      maxIdle="5" maxWait="100" 
      username="testadmin" 
      url="jdbc:oracle:thin:@10.5.43.100:1521:ORCL" 
      maxActive="5" removeAbandoned="true" removeAbandonedTimeout="180" logAbandoned="true"/>

	<Resource name="mytest2"
     auth="Container" type="javax.sql.DataSource"
      password="admin" 
      driverClassName="net.sourceforge.jtds.jdbc.Driver" 
      maxIdle="5" maxWait="100" 
      username="admin" 
      url="jdbc:jtds:sqlserver://10.5.10.66:1433/PMTXX" 
      maxActive="5" removeAbandoned="true" removeAbandonedTimeout="180" logAbandoned="true"/>

			
			</Context> 

 

启动tomcat之后会发现D:\apache-tomcat-6.0.29\conf\Catalina\localhost会多出一个xml文件

posted @ 2014-07-25 10:39  哈特中尉  阅读(143)  评论(0编辑  收藏  举报