<% @ Page ContentType = "Text / HTML; Charset = GB2312"%> <% @ page import = "java.sql. *"%>
<% string string string strs = ""; string strsEx = " ";" Com.mysql.jdbc.driver). Newinstance (); string url = "jdbc: mysql: // localhost: 3306 / samp_db"; string struser = "root"; string strpasswd = "123"; Connection conn = DriverManager.getConnection (url, strUser, strPasswd); Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); String strSql = "select * from student"; ResultSet rs = stmt.executeQuery (STRSQL); while (rs.next ()) {strname = rs.getstring ("name"); strsEx = rs.getstring ("sex"); out.print (strname); out.println (strsEx);} Stmt.close (); conn.close ();} catch (exception e) {E.PrintStackTrace ();}%> body> html>