//数据库test,表名test,用户名root,密码fanfei
<%@page contentType="text/html;charset=gb2312"%>
<%

java.sql.Connection sqlConn;
java.sql.Statement sqlStmt;
java.sql.ResultSet sqlRst;

Class.forName("org.gjt.mm.mysql.Driver").newInstance();
sqlConn=java.sql.DriverManager.getConnection
("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=gb2312", "root","fanfei");
sqlStmt=sqlConn.createStatement();
sqlRst=sqlStmt.executeQuery("select * from test");
%>
<html>
<head>
<title>JSP-JDBC-MYSQL</title>
</head>
<body>
<table border="1"  align="center">
<tr><td>DB CONNECT OK , </td></tr>
<tr>
<th>
name </th>
<th>
password </th>
</tr>
<% while(sqlRst.next()) {%>
<tr>
<td> <%=sqlRst.getString("name")%></td>
<td><%=sqlRst.getString("password")%></td>
</tr>
<%}%>
</table>
</body>
</html>
<%
sqlRst.close();
sqlStmt.close();
sqlConn.close();
%>