`

Tomcat JNDI configuration

    博客分类:
  • Java
阅读更多

 

Tomcat JNDI configuration

 

 

通常我们 web 项目都需要连DB,都会有 META-INF context.xml 文件:

 

<?xml version='1.0' encoding='utf-8'?>

<Context crossContext="true" path="/test" docBase="test" debug="0" reloadable="false">

</Context>

 

另外 Catalina .base/conf 下有 server.xml 中配置 JNDI Resource:

 

<Resource name="jdbc/test"

          auth="Container" type="javax.sql.DataSource"

  username="test" password="pass"

  driverClassName="com.inet.ora.OraDriver"

  url="jdbc:inetora:localhost:testdb"

  initialSize="10" maxActive="50" maxIdle="10" maxWait="10000"

  connectionProperties="streamstolob=true"

  testOnBorrow="true" timeBetweenEvictionRunsMillis="300000"

  removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"

  validationQuery="select 1 from dual"/>

 

Catalina .base/conf/context.xml 中也可以添加 Resource ,以及 ResourceLink

<Resource name="jdbc/test"

          auth="Container" type="javax.sql.DataSource"

  username="test" password="pass"

  driverClassName="com.inet.ora.OraDriver"

  url="jdbc:inetora:localhost:testdb"

  initialSize="10" maxActive="50" maxIdle="10" maxWait="10000"

  connectionProperties="streamstolob=true"

  testOnBorrow="true" timeBetweenEvictionRunsMillis="300000"

  removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"

  validationQuery="select 1 from dual"/>

 

<ResourceLink global="jdbc/test" name="jdbc/test" type="javax.sql.DataSource"/>

 

web application deployment on tomcat:

  1. 删除 META -INF/context.xml, Catalina .base/conf/context.xml 中添加 JNDI Resource and ResourceLink ( 推荐使用 )
  2. 删除 META-INF/context.xml, Catalina.base/conf/server.xml 中配置 JNDI Resource, Catalina.base/conf/context.xml 中添加 ResourceLink
  3. 保留项目里 META -INF/context.xml ,在 Catalina .base/conf/ 中的 server.xml context.xml 中添加 JNDI Resource.
  4. 移动 META -INF/context.xml Catalina .base/conf/ Catalina / localhost 中,并改名为项目名 .xml, test.xml, Catalina .base/conf/server.xml or context.xml 中配置 JNDI Resource
分享到:
评论

相关推荐

    Tomcat The Definitive Guide, 2nd Edition(PDF)

    Configuring Tomcat-including realms, roles, users, servlet sessions, and JNDI resources including JDBC DataSources * * Deploying web applications-individual servlets and JSP pages, and web ...

    tomcat权威指南第二版.pdf

    Accessing JNDI and JDBC Resources 75 Servlet Auto-Reloading 78 Customized User Directories 78 Tomcat Example Applications 80 Common Gateway Interface (CGI) 80 The Tomcat Admin Webapp 82 3. Deploying ...

    Tomcat 5 Unleashed

    In Part 1 of this book, we'll get started by downloading Tomcat and doing basic configuration, security, and administration. Here we'll take the first steps in creating a production-quality Tomcat ...

    Jetty中文手册

    jetty-env.xml–JNDI configuration webdefault.xml–Pre-web.xml configuration override-web.xml–Post-web.xml configuration 特性参考 SSL Connectors参考 QoSFilter参考 DoSFilter参考 FAQ Contributing ...

    spring-boot-reference.pdf

    16.2. Disabling Specific Auto-configuration Classes 17. Spring Beans and Dependency Injection 18. Using the @SpringBootApplication Annotation 19. Running Your Application 19.1. Running from an IDE ...

    Apache Geronimo 2.1_ Quick Reference.pdf

    Tomcat specific configuration 110 Jetty specific configuration 111 Sample web application 112 EJB applications 112 Annotations 113 EJB deployment plan 116 Sample EJB application 118 Deploy the ...

    基于J2EE框架的个人博客系统项目毕业设计论文(源码和论文)

    Tomcat是一个免费的开源的Serlvet容器,在Tomcat中,应用程序的部署很简单,你只需将你的WAR放到Tomcat的webapp目录下,Tomcat会自动检测到这个文件,并将其解压。你在浏览器中访问这个应用的Jsp时,通常第一次会很...

    《程序天下:J2EE整合详解与典型案例》光盘源码

    12.2.1 Configuration(配置Connection) 12.2.2 SessionFactory(Connection工厂) 12.2.3 Session(提供Connection) 12.3 使用Hibernate操作数据库的示例 12.3.1 创建数据库表 12.3.2 编写表对应的JavaBean ...

    搞定J2EE:STRUTS+SPRING+HIBERNATE整合详解与典型案例 (2)

    12.2.1 Configuration(配置Connection) 12.2.2 SessionFactory(Connection工厂) 12.2.3 Session(提供Connection) 12.3 使用Hibernate操作数据库的示例 12.3.1 创建数据库表 12.3.2 编写表对应的JavaBean ...

    搞定J2EE:STRUTS+SPRING+HIBERNATE整合详解与典型案例 (1)

    12.2.1 Configuration(配置Connection) 12.2.2 SessionFactory(Connection工厂) 12.2.3 Session(提供Connection) 12.3 使用Hibernate操作数据库的示例 12.3.1 创建数据库表 12.3.2 编写表对应的JavaBean ...

    搞定J2EE:STRUTS+SPRING+HIBERNATE整合详解与典型案例 (3)

    12.2.1 Configuration(配置Connection) 12.2.2 SessionFactory(Connection工厂) 12.2.3 Session(提供Connection) 12.3 使用Hibernate操作数据库的示例 12.3.1 创建数据库表 12.3.2 编写表对应的JavaBean ...

    《JVoiceXML 0.7 用户指南》-电子文档下载(PDF)(英文)

    3.4 Tomcat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4 Installation 5 5 Starting the Voice Browser 5 5.1 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 5.2 ...

    springboot参考指南

    定位auto-configuration候选者 iii. 36.3. Condition注解 i. 36.3.1. Class条件 ii. 36.3.2. Bean条件 iii. 36.3.3. Property条件 iv. 36.3.4. Resource条件 v. 36.3.5. Web Application条件 vi. 36.3.6. SpEL...

    jpivot学习总结.doc

    role 否 String 是 Role 的名称,如: role=”tomcat” 就允许当前用户角色为 tomcat 的访问该控件, role=”!tomcat” 则就允许除角色为 tomcat 以外的所有的用户访问。 query 是 OlapModel 是 一个 ...

    Geoserver用户手册

    1 Introduction 3 1.1 Overview . . . . . . . . ....1.2 History ....1.3 Getting involved ....1.4 License ....2.1 Windows installer ....2.2 Windows binary ....2.3 Mac OS X installer ....2.4 Mac OS X binary ....

Global site tag (gtag.js) - Google Analytics