Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »


This page is a work in progress.

This page is a work in progress. This info box will be removed once complete.

Container managed connection pool is used to connect to the Postgres database. 

Tomcat JDBC pool is used as the connection pool. The connection pool is defined the configuration file context.xml which and is initialized as a container managed resource. The connection pool must be packaged in the META_INF folder of a war file or jar file and is read and initialized before the spring context. Its managed by the container(tomcat) and not spring.

The connection pool is then registered as the datasource in spring application by using JNDI in the persistence_postgres.xml as shown below

<bean id="openSRPDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">

   <property name="jndiName" value="java:comp/env/jdbc/openSRPDB" />

</bean>

Note" the JNDI value in   java:comp/env/jdbc/openSRPDB the bean must match to the Resource name jdbc/openSRPDB.
java:comp/env is the node in the JNDI tree(in-memory global hashtable) where you can find properties for the current Java EE. JDNI resources must be prefixed with "java:comp/env" when doing JNDI lookups by name

context.xml
<Context>
<Resource
		name="jdbc/openSRPDB"
		auth="Container"
		type="javax.sql.DataSource"
		factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
		initialSize="5"
		maxActive="55"
		maxIdle="21"
		minIdle="13"
		timeBetweenEvictionRunsMillis="34000"
		minEvictableIdleTimeMillis="55000"
		validationQuery="SELECT 1"
		validationInterval="34"
		testOnBorrow="true"
		removeAbandoned="true"
		removeAbandonedTimeout="233"
		username="opensrp_admin"
		password="admin"
		driverClassName="org.postgresql.Driver"
		url="jdbc:postgresql://localhost:5432/opensrp"
     />

</Context>

The parameters control how the connection pool and can be be tweeked further depending on environment and load. Use the documentation below to expore further advanced  parameters 
Documentation 
https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.