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 ();
}