• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TOO MANY CONNCTIONS

 
Sanjay Rawat
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.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34965
378
Eclipse IDE Java VI Editor
  • 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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic