Connection between DBCP, c3p0, and JNDI in database connection pool technology

Source: Internet
Author: User

DBCP and c3p0 are two database connection pools.
Both connection pools are the connection pools recommended by hibernate.
DBCP is a database connection pool that relies on the Jakarta commons-pool Object pool mechanism. The Tomcat data source uses DBCP.
C3p0 is an open-source JDBC connection pool. It is released together with hibernate in the lib directory, including datasources objects for connection and statement pools that implement the jdbc3 and jdbc2 extension specifications.
JNDI (Java Naming and Directory Interface) is a standard Java Naming System interface provided by Sun. JNDI provides a unified client API through the implementation of jndi spi through different access provider interfaces, the Administrator maps the jndi api to a specific naming service and directory system, so that Java applications can interact with these naming services and directory services.
JNDI and JDBC:
JNDI provides a unified method for searching and accessing services on the network. By specifying a resource name, the name corresponds to a record in the database or naming service, and returns the information required for database connection establishment.
References:
Http://java.sun.com/products/jndi/examples.html
Http://java.sun.com/products/jndi/serviceproviders.html
Common JNDI operations:
Void BIND (string sname, object);-binding: Process of associating names with objects
Void rebind (string sname, object);-rebind: Used to rebind an object with an existing name
Void unbind (string sname);-release: Used to release an object from the directory.
Void Lookup (string sname, object);-query: returns an object of the total directory.
Void Rename (string soldname, string snewname);-Rename: used to modify the name bound to the object name
Namingenumeration listbinding (string sname);-list: list of objects bound to a specific context
Namingenumeration list (string sname );
Code example: Get the name, class name, and bound object again.
Namingenumeration namenumlist = ctxt. listbinding ("cntxtname ");
...
While (namenumlist. hasmore ()){
Binding BND = (binding) namenumlist. Next ();
String sobjname = BND. getname ();
String sclassname = BND. getclassname ();
Someobject objlocal = (someobject) BND. GetObject ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.