Chapter 13: JDBC Connectivity The role of a

Chapter 13: JDBC Connectivity The role of a Web-tier container as an intermediary between client Web applications and an RDBMS is defined by the set of J2EE specifications most recently in the Servlet 2.4 specifications and the JDBC 3 specifications (located at http://jcp.org/aboutJava/communityprocess/final/jsr154/and http://java.sun.com/products/jdbc/download.html#corespec30). JDBC 4 specification is also at the same link, but Tomcat 6 support is forthcoming. The value-added service that Tomcat provides is compliant with these specifications, and is documented as a three-tier architecture (see Figure 13-3 ). Jakarta Commons DBCP pool manager JNDI emulation 1. Lookup via JNDI Referenced JDBC data source 2. Receive pooled data source Tomcat Container JNDI Resource Definitions in server.xml Web application Figure 13-3: JNDI lookup of a JDBC data source in Tomcat 6 Figure 13-3 shows how JDBC drivers are configured with Tomcat as JNDI resources. These resources are made available during Web application runtime via standard JNDI lookups. The following steps are depicted in the diagram: 1. A Web application obtains a JNDI InitialContext from Tomcat; it then performs a lookup on the resource (JDBC data source) by name. 2. Tomcat handles the JNDI lookup by consulting the configuration files ( context.xml, server.xml, and web.xml) to determine which JDBC driver to use for obtaining a data source. Tomcat can also use database connection pooling (DBCP) to pool the connections made; the connections obtained from Tomcat are logical connections. Even though no true JNDI-compatible directory services are involved, the Tomcat container emulates the action of a JNDI provider. This enables code that is written with JNDI as the JDBC data source lookup mechanism to work within the Tomcat container (and other Servlet 2.4 compliant application servers). As you can see in Figure 13-3 , Tomcat 6 does more than merely provide JNDI emulation. It can also provide database connection pooling. Tomcat 6 uses Apache Commons DBCP (database connection pooling) for its built-in pool manager functionality.

If you looking for unlimited one inclusive web hosting plan please check web hosting plan website.

Comments are closed.