Looking for Tomcat's database connection pool configuration method, busy one morning, finally succeeded, huh, huh
Operating system: Windows XP SP1
1. Install JDK 5.0 Update 1
Download: http://java.sun.com/
Assume that the installation path is d: /java/jdk1.5.0_01 Set the environment variable (Control Panel -> System -> Advanced) Java_Home = D: /JAVA/JDK1.5.0_01ClassPath = .; d: /java/jdk1.5.0_01/ LIB / DT.JAR; D: /JAVA/JDK1.5.0_01/lib/tools.jar; Path = path;% java_home% / bin
2. Install Tomcat 5.5.4
Download: http://jakarta.apache.org/site/binIndex.cgi (http://apache.freeelamp.com/jakarta/tomcat-5/v5.5.4/bin/jakarta-tomcat-5.5.4.exe)
Installing D: / Tomcat 5.5, installing Tomcat 5.5 requires JRE 5.0. If the first installed JDK5.0 path is not automatically identified, you need to manually specify the path to JRE5.0.
Set environment variables Catalina_Home = D: / Tomcat 5.5
------------------------------------------ Configuration D: / Tomcat 5.5 / CONF / Server.xml ----------------------------------------- Host> host> plus the following configuration information
Where the Path sets the name of the virtual directory, DocBase is configured for the actual path in the system
D: / dbtest directory structure | ----- Web-inf ---- Web.xml | ----- Classes | ----- LIB ------------- ------------------------------ Configuration D: /DBTEST/Web-inf/web.xml ------- ------------------------------------ Between test tomcat h1> <% try { Context initCtx = new InitialContext (); DataSource ds = (DataSource) initCtx.lookup ( "java: comp / env / jdbc / connectDB"); Connection conn = ds.getConnection (); Statement stmt = conn.createStatement (); ResultSet RS = stmt.executequery ("Select * from test"); While (rs.next ()) {%> first: <% = rs.getstring (1)%> <%}%> <% out.print ("sucssful! / n");%> <% rs.close (); stmt.close ();} catch (exception e) {E.PrintStackTrace ();}%> body> html> Note Before you first build the corresponding test data in SQL Server
Ok, now I am visiting http: // localhost: 8080 / dbtest / testdb.jsp in the browser.