Tomcat5 + SQLServer connection pool configuration method

xiaoxiao2021-03-06  113

Enter the Tomcat's Admin management interface, click DataSource to configure your parameters, the configured parameters are as follows (JDBC drivers to jtds): JNDI Name: JDBC / MySQLData Source URL: JDBC: JTDS: SQLServer: // localhost: 1433 / testjdbc Driver Class: net.sourceforge.jtds.jdbc.DriverUser Name: testPassword: testMax Active Connections:. 4Max Idle Connections:. 2Max Wait for Connection:. 5000Validation Query: // without adding in% TOMCAT_HOME% / conf / Catalina / localhost under Find your web application corresponding to the .xml file, such as Test.xml, and add the code under this file:

is successful, with the following code test: <% @ Page Import = "java.sql. *"% > <% @ page import = "javax.naming. *"%> <% @ page import = "javax.sql. *"%> <% try {context initX = new initialContext (); context ctx = (context) InitctX .lookup ("java: comp / ENV"); DataSource DS = (Datasource) CTX.lookup ("JDBC / MySQL"); connection conn = ds.getConnection (); statement stmt = conn.createstatement (); string strampl = "Select * from userinfo"; ResultSet RS = Stmt.executeQuery (strsql); while (rs.next ()) {Out.println (rs.getstring (1)) ;?}} catch (exception ex) {EX. PrintStackTrace ();}%>

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

New Post(0)