<% String DBDriver = "org.gjt.mm.mysql.Driver"; String DBUrl = "jdbc:mysql://localhost:3306/cheng_base"; String DBUser = "root"; String DBPassword = "cheng"; Class.forName(DBDriver); Connection conn = null; try { conn = DriverManager.getConnection(DBUrl,DBUser,DBPassword); out.println("数据库连接成功!"); } catch(Exception ex) { //out.println("连接失败!"); ex.printStackTrace(); //return ; } Statement sqlStatement = conn.createStatement(); String sql = "select * from cheng"; ResultSet rs = sqlStatement.executeQuery(sql); while(rs.next()) { %> <%=rs.getString(1)%> <%=rs.getString(2)%> 你是 <%=rs.getString(3)%> ! <br /> <% } %>