By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,913 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,913 IT Pros & Developers. It's quick & easy.

Connections does not returned to pool.I am using DB2 9.1 and Tomcat 7.0.47

P: 1
Connections does not returned to the pool, the size of the connection pool increases more than the maxSize. I am using the `DB2 9.1`and `Tomcat 7.0.47`.
To connect to database I have to use db2jcc.jar & db2jcc_license_cu.jar of DB2 9.5 as jars of 9.1 does not work properly.
I am setting `maxSize = "30"` but when I see the database connection log it shows connection more than `30` and it increases to `100` and after that database gets locked. I am using Applet, Servlet & Javabeans (for business logic).I also close all my connections,statements in my applications.

I have configure the Tomcat by changing the `web.xml`, `context.xml` and `server.xml` (which are at the conf directry of the server). The configurations are as follows
**web.xml**
Expand|Select|Wrap|Line Numbers
  1. <web-app> <resource-ref> <description>DB2 Datasource example</description> <res-ref-name>jdbc/datasourcename</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </web-app>
  2.  
**context.xml**
Expand|Select|Wrap|Line Numbers
  1.  
  2. <Context> <ResourceLink name="jdbc/datasourcename" global="jdbc/datasourcename" type="javax.sql.DataSource" /> </Context>
  3.  
SERVER.XML

Expand|Select|Wrap|Line Numbers
  1. <GlobalNamingResources> <Resource name="UserDatabase" auth="Container"
  2. type="org.apache.catalina.UserDatabase"
  3. description="User database that can be updated and saved"
  4. factory="org.apache.catalina.users.MemoryUserDatab aseFactory"
  5. pathname="conf/tomcat-users.xml" /> <Resource name="jdbc/datasourcename" auth="Container" 
  6. type="javax.sql.DataSource"
  7. factory="org.apache.tomcat.jdbc.pool.DataSourceFac tory"
  8. testWhileIdle="true"
  9. testOnBorrow="true"
  10. testOnReturn="false"
  11. validationQuery="SELECT 1"
  12. validationInterval="30000"
  13. timeBetweenEvictionRunsMillis="30000"
  14. maxActive="30"
  15. minIdle="1"
  16. maxWait="10000"
  17. initialSize="1"
  18. removeAbandonedTimeout="60"
  19. logAbandoned="true"
  20. removeAbandoned="true"
  21. closeMethod="close" 
  22. abandonWhenPercentageFull="60"
  23. minEvictableIdleTimeMillis="3000"
  24. jmxEnabled="true" jdbcInterceptors="org.apache.tomcat.jdbc.pool.inte rceptor.ConnectionState;org.apache.tomcat.jdbc.poo l.interceptor.StatementFinalizer"
  25. alternateUsernameAllowed="true"
  26. username="user"
  27. password="pass"    
  28. driverClassName="com.ibm.db2.jcc.DB2Driver"    
  29. url="jdbc:db2:://127.0.0.1:50000/DBname" /> </GlobalNamingResources>
  30.  
Mar 27 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.