First patch JSP code to try

xiaoxiao2021-03-06  104

<% @ 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 ();}%>

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

New Post(0)