将数据库连接从 WAS 迁移到 TOMCAT 7
Migrate database connection from WAS to TOMCAT 7
我的 WAS server.xml 中有这样一个数据库连接:
<dataSource jdbcDriverRef="ORACLEDriver" jndiName="jdbc/jndiNameExample">
<properties.oracle
URL="*******"
password="****" user="****" />
</dataSource>
<jdbcDriver id="ORACLEDriver" libraryRef="ORACLE" />
<library id="ORACLE">
<fileset dir="C:\route1\route" includes="ojdbc6.jar" />
</library>
如何将此数据库连接迁移到 TOMCAT 7?
谢谢!
将 ojdbc6.jar 添加到 tomcat 库目录。
tomcat server.xml
<Resource auth="Container"
driverClassName="oracle.jdbc.OracleDriver"
global="jdbc/jndiNameExample"
maxActive="100"
maxIdle="20"
maxWait="10000"
minIdle="5"
name="jdbc/jndiNameExample"
password="password"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@host:1521:ServiceName"
username="username"/>
tomcat context.xml
<ResourceLink name="jdbc/jndiNameExample"
global="jdbc/jndiNameExample"
auth="Container"
type="javax.sql.DataSource" />
WEB-INF/web.xml
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/jndiNameExample</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
连接代码
Context ctx = new InitialContext();
Context envContext = (Context) ctx.lookup("java:/comp/env");
javax.sql.DataSource ds = (javax.sql.DataSource) envContext.lookup ("java:/comp/env/jdbc/jndiNameExample");
我的 WAS server.xml 中有这样一个数据库连接:
<dataSource jdbcDriverRef="ORACLEDriver" jndiName="jdbc/jndiNameExample">
<properties.oracle
URL="*******"
password="****" user="****" />
</dataSource>
<jdbcDriver id="ORACLEDriver" libraryRef="ORACLE" />
<library id="ORACLE">
<fileset dir="C:\route1\route" includes="ojdbc6.jar" />
</library>
如何将此数据库连接迁移到 TOMCAT 7?
谢谢!
将 ojdbc6.jar 添加到 tomcat 库目录。
tomcat server.xml
<Resource auth="Container"
driverClassName="oracle.jdbc.OracleDriver"
global="jdbc/jndiNameExample"
maxActive="100"
maxIdle="20"
maxWait="10000"
minIdle="5"
name="jdbc/jndiNameExample"
password="password"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@host:1521:ServiceName"
username="username"/>
tomcat context.xml
<ResourceLink name="jdbc/jndiNameExample"
global="jdbc/jndiNameExample"
auth="Container"
type="javax.sql.DataSource" />
WEB-INF/web.xml
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/jndiNameExample</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
连接代码
Context ctx = new InitialContext();
Context envContext = (Context) ctx.lookup("java:/comp/env");
javax.sql.DataSource ds = (javax.sql.DataSource) envContext.lookup ("java:/comp/env/jdbc/jndiNameExample");