Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info
titleThis 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

...

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

Code Block
languagexml
titlecontext.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>

...