<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*" %>
<html>
<body>
<%
String strName = "";
String strSex = "" ;
try
{
Class.forName("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>