Tomcat5.5 First Series (3) - Connection Pool

xiaoxiao2021-03-06  41

(Repost, please keep the original information) The previous use of Tomcat5.5 use, this time, the connection pool of the data usually used in Tomcat5.5 is established and tested PS: due to the test Many, so after release until today, I will update today, I'm seeing officials forgiveness. :-) OK, NOW is Go ~~~~ dark blue (liuyxit) - 2005/01/05 database and JDBC driver preparation: mysql: mysql-4.1. 8-win.zipmysql-connector-java-3.0.16-ga.zipwww.mysql.org Download MSSQL: http://www.microsoft.com/china/sql/downloads/jdbc_sp1.asp 1, mysql1. Mysql, unzip JDBC driver (huh, nonsense) 2. Put JDBC Drive MySQL-Connector-Java-3.0.16-Ga-bin.jar to Tomcat_Home / Common / Lib 3. At this time we built a test JDBC and database Normal JSP page mysql.jsp (placed in the second-construction virtual directory SNOW, the physical path is in E: / WWW / SNOW), the content is as follows: <% @ Page ContentType = "text / html; charSet = GBK"% > <% @ Page import = "java.sql. *"%>

<% out.print ("test start
"); class.forname ("com.mysql.jdbc.driver). Newinstance (); string url =" jdbc: mysql: // localhost / snow? user = root & password = liuyxit & useUnicode = true & characterEncoding = GB2312 "; // above the corresponding change snow into your database name, user root for your login, liuyxit for the user's password Connection conn = DriverManager.getConnection (url); Statement stmt = conn.createStatement (); String query = "select username from sys_user"; // Corresponding to the table name and field name ResultSet RS = stmt.executeQuery (query); while (rs.next ()) {string s = rs.getstring (1 ); // Check your field is not a character type, not using getString, use getBoolean, etc. according to field classes,} conn.close (); Out.print (" My test ends
- Deep Blue ");%> // - JSP - now you can restart Tomcat, please ask: http: // localhost: 8080 / snow / mysql .jsp See your database data? If OK is going on next 4. Change the Tomcat_Home / CONF / CATALINA / LOCALHOST / SNW.XML in China to the following:

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

New Post(0)