Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How commons dbcp (and other connection pools) manage open statements and resultsets?

Tags:

Specifically, when I return a connection to the pool, does dbcp (and other connection pools) close the statements and resultsets for me?

Or should I be closing these myself?

like image 555
Tahir Akhtar Avatar asked Jul 01 '09 08:07

Tahir Akhtar


People also ask

How does DBCP connection pool work?

The connection user name to be passed to our JDBC driver to establish a connection. The connection password to be passed to our JDBC driver to establish a connection. The connection URL to be passed to our JDBC driver to establish a connection. The fully qualified Java class name of the JDBC driver to be used.

What is the use of Commons DBCP?

This Commons package provides an opportunity to coordinate the efforts required to create and maintain an efficient, feature-rich package under the ASF license. The commons-dbcp2 artifact relies on code in the commons-pool2 artifact to provide the underlying object pool mechanisms.

What is connection pooling and what are some of its benefits?

Using connection pools helps to both alleviate connection management overhead and decrease development tasks for data access. Each time an application attempts to access a backend store (such as a database), it requires resources to create, maintain, and release a connection to that datastore.

How does JDBC connection pooling work?

Via the JDBC resource, the application gets a database connection. Behind the scenes, the application server retrieves a physical connection from the connection pool that corresponds to the database. The pool defines connection attributes such as the database name (URL), user name, and password.


1 Answers

OK I see that statements are closed by dbcp in DelegatingConnection.passivate() and DelegatingStatement.close() closes the resultsets.

like image 182
Tahir Akhtar Avatar answered Oct 12 '22 08:10

Tahir Akhtar