Oracle 11g UCP with Tomcat

Download Instant Client Package – Basic and SQL*Plus from Oracle.
Unzip packages to /Applications/oracle/instantclient_10_2.
Add the following to ~/.bash_profile:

export DYLD_LIBRARY_PATH=/Applications/oracle/instantclient_10_2
export TNS_ADMIN=/Applications/oracle/instantclient_10_2
export PATH=$PATH:$DYLD_LIBRARY_PATH

Ensure you have the below tnsnames.ora file in TNS_ADMIN so as to connect to the server from client using connect string: sqlplus <username>@xyz


xyz =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(PORT = <port>)
(HOST = <server_name>)
)
(CONNECT_DATA = (SID = <SID>))
)
Add the following to your tomcat/conf/server.xml file:

<GlobalNamingResources>

<Resource
name="jdbc/<pool_jndi_name>"
auth="Container"
url="jdbc:oracle:thin:@<server_name>:<port>:<SID>"
user="<username>"
password="<password>"
factory="oracle.ucp.jdbc.PoolDataSourceImpl"
type="oracle.ucp.jdbc.PoolDataSource"
connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource"
connectionPoolName="<pool_name>"
connectionWaitTimeout="30"
minPoolSize="5"
maxPoolSize="25"
inactiveConnectionTimeout="20"
timeoutCheckInterval="60"
validateConnectionOnBorrow="true"
sqlForValidateConnection="SELECT 1 FROM DUAL" />

...
and add the ucp.jar to tomcat/libs directory.

Wednesday, July 7th, 2010 Code, Database, Development, Oracle, Tomcat

No comments yet.

Leave a comment

You must be logged in to post a comment.

Agile CTO