Chapter 13: JDBC Connectivity These configuration steps are identical to what was necessary when DBCP was used earlier in the setup of JDBCTest.jsp. In general, this would be the way to configure any alternative pooling mechanism that is compatible with Tomcat 6 s JNDI emulation. Last but not least, a test JSP file must be created that makes use of the jdbc/WroxC3P0 JNDI resource. To create this JSP file, it is necessary to make only a very small change to JDBCTest.jsp. The change required is highlighted in the following snippet, and the completed file is placed into the jsp/wroxjdbc subdirectory of the examples Web application. The new JSP is called C3P0Test2.jsp. <%@ taglib uri= http://java.sun.com/jsp/jstl/sql prefix= sql %> <%@ taglib uri= http://java.sun.com/jsp/jstl/core prefix= c %> <%@ page errorPage= errorpg.jsp %>
select * from employee;
JDBC JNDI Resource Test Using C3P0
… Note that the code of JDBCTest.jspand C3P0Test2.jspis essentially identical. This demonstrates the advantage of decoupling the application code from the RDBMS accessed via JNDI. The same code can be used with connection pooling mechanisms from different vendors without change; only the configuration must be modified. Testing c3p0 with Tomcat 6 JNDI -Compatible Lookup To test c3p0 s JNDI-compatible operation mode, shut down Tomcat 6 and restart it. This restart is not strictly necessary. However, restarting Tomcat ensures that you begin with a clean slate, as the previous example loaded c3p0. Next, try to access the JSP via the following URL: http://localhost:8080/examples/jsp/wroxjdbc/C3P0Test2.jsp The output from this example is again similar to what is shown in Figure 13-6 . Note that the output is indistinguishable (other than the new title) from that of JDBCTest.jspor C3P0Test2.jsp, although they each use distinctively different pooling code to access and manage the JDBC connection used. As of this writing (in early 2007), the c3p0 project is alive and well on SourceForge, which has the latest code updates and bug fixes. Previous versions of the book used a different and now defunct pool manager. This does bring up the issue of ongoing support for anyone who may decide to adopt an alternative pool manager.
For high quality website hosting services please check java web hosting website.
Posted in tomcat | No Comments »
Monday, August 10th, 2009
Posted in tomcat | No Comments »
Sunday, August 9th, 2009
Posted in tomcat | No Comments »
Saturday, August 8th, 2009
Posted in tomcat | No Comments »
Saturday, August 8th, 2009
Posted in tomcat | No Comments »
Friday, August 7th, 2009
Posted in tomcat | No Comments »
Thursday, August 6th, 2009
Posted in tomcat | No Comments »
Thursday, August 6th, 2009
Posted in tomcat | No Comments »
Wednesday, August 5th, 2009
Posted in tomcat | No Comments »
Tuesday, August 4th, 2009
Posted in tomcat | No Comments »