Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

TOO MANY CONNCTIONS

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends

Iam getting an exception as "too many connection" by db after hitting db 10-20 times.
it works well in 10-20 hits to db but after that i got this error
is there anyother way to close the connection?,if i dont want to close the connection in my each jsp page.?.
my context.xml entry is like this
i set maxActive=30
maxidle=10
removeabondoned=true
removeabondonedtimeout=20
..
.
.
.
.

please help i dont want to close the connection in my each JSP page...
is there anyother way provided by APACHE to close the connetion and get the objects back in pool.

 
author & internet detective
Posts: 39986
806
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sanjay,
First of all, you shouldn't be using the Connection in any JSP page. The JSP is for rendering the view. All JDBC code should be in a Java class.

Second, you have to close the connection everyplace you use it. Whether that is a JSP or Java class it is the same thing. Every place that obtains a connection is responsible for closing it. Anything else is a connection leak.
 
Sanjay Rawat
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i will definitely pay attention on your word ,, But my question that ,i m using connection pool by apache and is there any way to close the connection without using conn.close() in every where..is there any functionality provide by apache.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. JDBC connections will eventually time out but you should not be relying on this. It's bad practice not to call close() in a finally block.
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic