|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
jar包已装入,连接正常。但显示如下错误
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'wel.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
SUccess<%=request.getParameter("user") %><br>
<a href="login.jsp">返回重新登陆</a>
<h1>用户信息列表</h1>
<%
//定义四个分页会用到的变量
int pageSize=3;
int pageNow=0;
int pageCount=3;
int rowCount=3;
String driverClass = "com.mysql.jdbc.Driver";
Class.forName(driverClass).newInstance();
Connection ct=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","");
//?autoReconnect=true&useUnicode=true&characterEncoding=gbk&mysqlEncoding=utf8
Statement sm=ct.createStatement();
ResultSet rs=sm.executeQuery("select * from student1");
if(rs.next()){
rowCount=rs.getInt(1);
}
if(rowCount%pageSize==0){
pageCount=rowCount/pageSize;
}else{pageCount = rowCount/pageSize+1;
}
//查询需要显示的记录
rs=sm.executeQuery("select top"+pageSize
+" * from student1 where userid not in (select top "
+pageSize*(pageNow-1)+" userid from student1)");
%>
<table border="1">
<tr><td>用户id</td><td>用户名字</td><td>密码</td></tr>
</table>
<%
while(rs.next()){
%>
<tr><td><%=rs.getInt(1) %></td><td><%=rs.getInt(2) %></td>
<td><%=rs.getInt(3) %></td></tr>
<%
}
%>
</table>
%>
</table>
</body>
</html>
|
|