TOMCAT5.5下配置JNDI步骤:
STEP1:
编辑 {$TOMCAT_INSTALL_PATH}CONFCONTEXT.XML
STEP2:
插入 {<Resource name="jdbc/text" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@192.168.20.10:1521:rdoa" username="*****" password="****" maxActive="20" maxIdle="10" maxWait="10000"/>}
STEP3:
编辑 WEB 应用程序下的 WEB-INFWEB.XML
STEP4:
插入 {
<resource-ref>
<description>postgreSQL Datasource example</description>
<res-ref-name>jdbc/text</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
}
通过以上配置后再web应用通过以下代码访问:
Context ctx = new InitialContext();
DataSource ds=(DataSource) Context.lookup("java:comp/env/jdbc/text");
添加新评论0 条评论