First, the environment configuration first adds the driver to the classpath. 1. Drive storage position when connecting MySQL: Drive Name: mysql-connector-java-3.1.5-gamma-bin.jar path: Tomcat5.5/Common / lib restart Tomcat takes effect after Tomcat. 2. Drive storage position when connecting Oracle: Drive Name: Classes12.jar Path: Tomcat5.5 / Common / LIB restart Tomcat take effect. Second, the test code <% @ page contentty = "text / html; charSet = GB2312"%> <% @ page import = "java.sql. *"%> < body> <% Class.forName ( "org.gjt.mm.mysql.Driver") newInstance (); String url =. "jdbc:? mysql: // localhost / db_name user = yourusername & password = yourpassword & useUnicode = true & characterEncoding = GB2312"; Connection conn = DriverManager.getConnection (url); Statement stmt = conn.createStatement (); String query = "select field_name from table_name order by id"; ResultSet rs = stmt.executeQuery (query); while (rs.next ()) {String s = rs.getstring ("Field_Name"); // Sight is not a character type, otherwise you can't use getString, use getBoolean, etc. according to field classes, OutBoolean, etc.); }%> body> html>