<% @ Page contentType = "text/html; charset = gb2312" %>
<% @ Page import = "java. SQL. *" %>
<Html>
<Body>
<%
String strName = "";
String strSex = "";
Try
{
Class. forName ("com. MySQL (the best combination with PHP). jdbc. Driver"). newInstance ();
String url = "jdbc: MySQL (the best combination with PHP): // 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.exe cuteQuery (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>