JSP连接数据库access遇到问题。十万火急!
代码为:
<%@page contentType= "text/html; charset=gb2312 " %>
<%@page language= "java "%>
<%@page import= "java.io.* "%>
<%@page import= "java.util.* "%>
<%@page import= "java.util.Date* "%>
<%@page import= "java.sql.* "%>
<%@page import= "java.net.* "%>
<%@page import= "java.text.* "%>
<%
//-----------------------------
//留言显示程序lyidex.jsp
//-----------------------------
%>
<%
//判断是否是管理员的IP
String WebmasterIP= "10.0.0.1 ";
boolean IsWebmasterIP=false;
String RemoteAddr=new String();
RemoteAddr=request.getRemoteAddr();
if(RemoteAddr.equals(WebmasterIp))
{
IsWebmasterIP=true;
}
int intPageSize; //一页显示的记录
int intRowCount=5; //记录总数
int intPageCount;//总页数
int intPage;//待显示的页数
String strPage;
int i;
//设置一页显示的记录
int PageSize=5;
//取得待显示页码
strPage=request.getParameter( "page ");
if(strPage==null){
//表明在QueryString中没有page这个参数,此时显示第一页数据
intpage=1;
}
else
{
//将字符串转换成整型
intPage=Integer.parseInt(strPage);
if(intPage <1) intPage=1;
}
//连接数据库
String DBDriver= "sun.jdbc.odbc.JdbcodbcDriver ";
try
{
Class.forName(DBDriver);
}
catch(
java.lang.ClassNotFoundException ae);
{
System.err.println( "ae: "+ae.getMessage());
}
String sConnStr= "jdbc:odbc:jspdb ";
Connection conn=null;
conn=DriverManger.getConnection(sConnStr, "sa ", " ");
String strSQl; //SQL语句
strSQL= "SELECT * FROM member WHERE flag=1 order by mydate desc ";
Statement stmt=
conn.creatStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet reslut=null;
try
{
result=stmt.executeQuery(strSQL);
}
catch(
SQLException be);
{
System.err.println( "be.executeQuery: "+be.getMessage());
}
result.last();
intRowCount=result.getRow();
//计算总页数
intPageCount=(intRowCount+intPageSize-1)/ intPageSize;
//调整待显示页码
if(intPage> intPageCount) intPage=intPageCount;
%>
<html>
<head>
<title> 留言显示 </title>
<me