Method for configuring Tomcat database connection pools in jbuilder

xiaoxiao2021-03-06  88

Configure Tomcat4.1.24 in jbuilder

1. There is a THIRDPARTY / JAKARTA-TOMCAT-4.1.24-Le-JDK14 directory in the JBuilder9 program directory, which is the Tomcat4.1 server comes with jbuilder 2. The database connection pool requires Commons-DBCP-1.1, Commons-Pool- 1.1 These two JAR packs, Toncat under JB has no comes with this two JAR package, which puts their COPY to the JBuilder9 program directory through the ThirdParty / Jakarta-Tomcat-4.1.24-Le-JDK14 // Common / lib3. Take JDBC Driver COPY to JBuilder9 Program Directory THIRDPARTY / JAKARTA-TOMCAT-4.1.24-Le-JDK14 // Common / LIB 4. Your Project has Tomcat's directory, you will see conf, WebApp, and Work three after entering Folder. Take a closer look at the configuration file inside the conf of a WebApp, modify the jb *********. XML (**** is a virtual path name), and the comment below is removed Then configure the database connection pool 5. My JB ****. XML example factory Org.apache.commons.dbcp.basicDataSourceFactory driverclassname < Value> com.mysql.jdbc.driver URL jdbc: mysql: // localhost / smsdata < / value> username root password maxactive 20 maxidle 0 maxwait -1

Removeabandoned true logabandoned false 6.jsp Test connection pool example <% @Page Import = "java.sql. *, javax.sql. *, javax.naming. *"%> <%! connection conn = null;%>

<%

CONTEXT CTX = NULL; try {ctx = new initialContext (); DataSource DS = (DataSource) CTX.lookup ("Java: Comp / Env / JDBC / ConnectDB"); conn = ds.getConnection ();

} Finally {try {if (ctx! = Null) {ctx.close ();}} catch (namingexception) {}}

%>

转载请注明原文地址:https://www.9cbs.com/read-97111.html

New Post(0)