有了数据库下面就要对数据库操作读取留言了!
下面列出显示留言的主要程序
<%@page import="java.sql.*"
import ="java.util.*"
import ="java.io.*"
contentType="text/html; charset=gb2312"
%>
<html>
<head>
<title>萍慧自由空间留言本</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<style type="text/css"><!--
body { font-size: 9pt}
td { font-size: 9pt}-->
</style>
</head>
<body>
<p align="center"><u><font size="5" face="华文新魏">萍慧自由空间留言本</font></u></p>
<table width="75%" border="1" bgcolor="#FFCCFF" bordercolorlight="#0000FF"
bordercolordark="#6666FF" cellpadding="0" cellspacing="0" align="center">
<tr>
<td colspan="5" height="202">
<%//下面处理用户的分页请求
String string_page;
int Page,RecoderPage,RecoderRow;
try{string_page=request.getParameter("page");
}catch (NullPointerException e){string_page="";}
try{Page=Integer.parseInt(string_page);
}catch(NumberFormatException e)
{Page=0;
}
java.sql.Connection sqlConn; //数据库连接对象
java.sql.Statement sqlStmt; //语句对象
java.sql.ResultSet sqlRst; //结果集对象
//登记JDBC驱动对象
Class.forName ("org.gjt.mm.mysql.Driver").newInstance ();
//连接数据库
sqlConn= java.sql.DriverManager.getConnection ("jdbc:mysql://localhost/p","test","");
//创建语句对象
sqlStmt=sqlConn.createStatement
(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
//执行Sql语句