Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2004, 03:42 AM
Authorized User
 
Join Date: Jul 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sherbir
Default Give me an explanation : Commons DBCP !

Hi all experts,

I am using the Tomcat server to deploy my web application. My web application accesses the MySQL database on the server.

I faced the problem of "Too many Connections" and went through a few websites regarding the error.

Finally, I found the solution and successfully implemented the Commons DBCP.

Now I want to know a few things :

DBCP creates a pool of connections. Connections r served on demand from this pool.

But still, in the code that I use in my JSP/Servlet, I have to explicitly close the connection....con.close().

Is it necessary to do that ?

What possible errors could I get if I don't do that ?

Could any1 please elaborate ?


Regards,
Sherbir
__________________
Regards,
Sherbir
 
Old September 29th, 2004, 05:13 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Sherbir,

In case an expert doesnt materialise...

Havent got round to connection pooling yet, but have started to look into it.

My understanding is that pooling should not close connections, the whole point is to avoid this, or more specifically the overhead of opening/closing the connections.

You must use JNDI to make use of connection pooling which is done in by editing both server.xml and web.xml.

Once this is done you can use the JNDI reference from jsp pages.

If using servlets or beans you also need to change code to use JNDI, in short you do NOT use JDBC directly in your code.

The code I tested with did not close the connection.

The best intro to this I have found is actually in the Tomcat documentation, section 9, JDBC data sources.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help!!! for DBCP borrowObject failed priyatowin Java Databases 2 February 22nd, 2008 04:29 AM
i need explanation ... amahja56 C++ Programming 2 October 28th, 2004 05:01 PM
Commons DBCP error !! sherbir Apache Tomcat 1 September 30th, 2004 04:08 AM
URGENT : Jakarta Commons FileUpload error sherbir Servlets 1 August 5th, 2004 06:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.