Tomcat环境下配置oracle数据源的方法
以JB2K5下自带的tomcat jakarta-tomcat- 4.1.30为例
完整版本(PDF文件)请到http://hbird.vicp.net/t-1598.html处下载
完整版本(PDF文件)请到http://hbird.vicp.net/t-1598.html处下载
Tomcat4(5)提供了一个与Java Enterprise Edition应用服务相兼容的JNDI--InitialContext实现实例。它的初始数据设置在$CATALINA_HOME/conf/server.xml文件里。并可能在网页应用环境描述(/WEB-INF/web.xml)里被下列元素引用:
<resource-ref>--资源参数,一般是数据库驱动程序、JavaMail Session、自定义类工厂等。
在$CATALINA_HOME/conf/server.xml里设置数据库连接池:
下面是tomcat配置样例的代码,必须放在<Host>和</Host>之间。
<!-- Tomcat Examples Context -->
<Context path="/examples" docBase="examples.war" debug="0"
reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_examples_log." suffix=".txt"
timestamp="true"/>
<Ejb name="ejb/EmplRecord" type="Entity"
home="com.wombat.empl.EmployeeRecordHome"
remote="com.wombat.empl.EmployeeRecord"/>
<!-- If you wanted the examples app to be able to edit the
user database, you would uncomment the following entry.
Of course, you would want to enable security on the
application as well, so this is not done by default!
The database object could be accessed like this:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
UserDatabase database =
(UserDatabase) envCtx.lookup("userDatabase");
-->
<!--
<ResourceLink name="userDatabase" global="UserDatabase"
type="org.apache.catalina.UserDatabase"/>
-->