Monday, August 5, 2013

Setting up the Data Source in TOMCAT with Oracle Universal Connection Pool

Setting up the Data Source in TOMCAT with Oracle Universal Connection Pool :

Download ojdbc6_g.jar and ucp.jar and copy the same to $TOMCAT_HOME/lib folder.

Add the Data Source setup in $TOMCAT_HOME/conf/server.xml as follows under 

<GlobalNamingResources> tag.

  <GlobalNamingResources>

  <Resource
       name="jdbc/SampleConnectionPool"
       auth="Container"
       factory="oracle.ucp.jdbc.PoolDataSourceImpl"
       type="oracle.ucp.jdbc.PoolDataSource"
       description="Pas testing UCP Pool in Tomcat"
       connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource"
       minPoolSize="2"
       maxPoolSize="5"
       inactiveConnectionTimeout="20"
       user="Sample"
       password="Sample"
       url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
            (HOST=localhost)(PORT=1522))(CONNECT_DATA=
            (SERVICE_NAME=SAMPLE)))"
       connectionPoolName="SampleConnectionPool"
       validateConnectionOnBorrow="true"
       sqlForValidateConnection="select 1 from DUAL" />


</GlobalNamingResources>


Change the database details accordingly.

Add Resource Link for the global JNDI resource in $TOMCAT_HOME/conf/context.xml file under <Context>.

<ResourceLink global="jdbc/SampleConnectionPool" name="jdbc/SampleConnectionPool" type="oracle.jdbc.pool.OracleDataSource"/>

Now jdbc/SampleConnectionPool can be used in the code to get the database connection.


Saturday, October 6, 2012

Unable to connect to tomcat home page when starting the server from eclipse

Unable to connect to tomcat home page when starting the server from eclipse:


When are we starting the tomcat server from eclipse, the server is getting started successfully as shown below but could not able to access the home – http://localhost:8080from the browser.



Double click the Tomcat server entry in the Servers tab; you'll get the server configuration. At the left column, under Server Locations, select Use Tomcat installation (Make sure no modules are published to do the changes for the existing server configuration)