1. Do not use Tomcat5 management page settings (no successful settings)
First add MSSQL driver in Tomcat5.0 / Common / LIB:
Msbase.jar, mssqlserver.jar, msutil.jar
2. Add: in Tomcat5 / Conf / Server.xml:
.......
.......
// below is added
// Added content end
Host>
3. The contents of Tomcat5.0 / WebApps / pool / web-inf / web.xml are as follows:
XML Version = "1.0" encoding = "ISO-8859-1"?>
Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"
"http://java.sun.com/dtd/web-app_2_3.dtd">
web-app>
4.Tomcat5.0 / WebApps / pool / testpool.jsp code is as follows:
<% @ Page ContentType = "text / html; charset = GB2312"%>
<% @ page import = "java.sql. *"%> <% @ Page Import = "javax.sql. *"%> <% @ page import = "javax.naming. *"%>
this is a tomcat datasource pool example<% Try {datasource ds = null; initialcontext ctx = new initialcontext (); if (ctx == null) throw new exception ("no matching context environment"); DS = (DataSource) CTX.lookup ("Java: comp) / env / jdbc / sqlsermidp "); if (ds == null) throw new exception (" There is no matching database "); connection conn = ds.getConnection (); statement stmt = conn.createstatement (); string strsql =" Select * from person_info "; ResultSet RS = Stmt.executeQuery (strsql); while (rs.next ()) {Out.Println (rs.getstring (1));%>
<%} Out.println (" Database connection success !!! ");} catch (exception e) {Out.println (" Somthing Error! ");} Finally {if (rs! = Null) rclose (); if (stmt! = Null) Stmt.close (); if (CNNN! = null) cnn.close (); if (CTX! = null) ctx.close ();
%> body> html>