My configuration and running environment is based on Tomcat5.0.28 JDBC3.0 SQLServer2000 JDK1.5, first of all the data drives on the web-inf / lib directory of the web application. First, pay attention to the following aspects: First: Tomcat version problem, I started to pursue a new version, I have a Tomcat5.5.7, I have done N days, I can't live, I don't know if the version has bugs, or when it is configured I didn't match it. Helpless a Tomcat5.0.28, a rough one, OK, success. Second: When the page page is browsing, the error is not available to find Driver, allowing the database to drive the database in the% Tomcat% / CommON / lib directory for Tomcat.
Second, the configuration file, the new% Tomcat% / conf / catalina / localhost sessiontest.xml file factory name> org.apache.commons.dbcp.basicdataasourcefactory value> parameter> maxactive name> 100 value> parameter> maxidle name> 30 value> parameter> maxwait name> -1 value> parameter> Username name> sa value> parameter> password name> 123 value> parameter> < Name> DriverclassName name> <
Value> com.microsoft.jdbc.sqlserver.sqlserverdriver value> parameter> URL name> JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = Test Value> parameter> resourceparams> context> Web.xml file under Web.xml file under Web.xml file XML Version = "1.0" encoding = "gb2312"?> Index.html Welcome-File> Index.htm Welcome-File> Index.jsp welcome-file> welcome-file-list> DB Connection description> jdbc / sessiontestdb res-ref-name> javax.sql.datasource res-type> container res-auth> resource-ref> web-app> 3, test page: <% @ page contenttype = "text / html; charset = GBK"%> <% @ Page Import = "java.sql. *"%> <% @ Page Import = "javax.sql. *"%> <% @ page import = "javax.naming. *"%> <% @ page session = "false"%> <% Datasour CE DS = NULL; try {initialcontext (); ds = (DataSource) CTX.lookup ("java: comp / env / jdbc / sessiontestdb"); connectiontestDB "); connection CONN = DS.GetConnection (); statement stmt = conn .createstatement (); string strsql = "select * from jnditest"; ResultSet RS = Stmt.executeQuery (strsql);