当前位置: 代码迷 >> Java Web开发 >> 基于javaweb的小小程序有关问题
  详细解决方案

基于javaweb的小小程序有关问题

热度:64   发布时间:2016-04-16 22:18:13.0
基于javaweb的小小程序问题
我从csdn下载了个停车场管理系统的源代码.可是运行到《收费记录》就报错了,可以帮看下这份代码错在那里好么,谢谢大神们
收费记录的jsp
<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="java.sql.*,com.jspdev.MoneyBean"%>
<%request.setCharacterEncoding("GB2312");
response.setCharacterEncoding("GB2312"); %>

<%!ResultSet rs = null;
//页面大小
int pageSize = 10;
//第几页
int pages = 1;
//总页数
int totalPage = 0;

String str = "";

public String showOnePage(ResultSet rs, int pages, int pageSize) {
str = "";
// 将记录指针定位到相应的位置
try {
rs.absolute((pages - 1) * pageSize + 1);
} catch (SQLException e) {
}

for (int i = 1; i <= pageSize; i++) {
str += displayOneResult(rs);
try {
if (!rs.next())
break;
} catch (Exception e) {
e.printStackTrace();
}
}
return str;
}

// 显示单行记录方法
public String displayOneResult(ResultSet rs) {
String text = "";
try {
text += "<tr align='center'>";
text +="<td>"+rs.getString("name")+"</td>";
text +="<td>"+rs.getInt("money")+"</td>";
text +="<td>"+rs.getString("username")+"</td>";
text +="<td>"+rs.getString("money_time")+"</td>";
text += "</tr>";
} catch (Exception e) {
e.printStackTrace();
}
return text;
}%>

<%
try {
rs = MoneyBean.getAllResults();
} catch (Exception e) {
out.println("访问数据库出错!");
}
%>
<html>

<body class="ss" leftmargin="0" topmargin="0" rightmargin="0" topmargin="0">
<img src="img/main.jpg" width="100%" height="100%"  style="position:absolute;top:0;left:0;right:100;bottom:500;z-index:-1">

<p align="center">
<font size="5" face="楷体_GB2312" color="#0000FF">停车场收费记录查看</font>
</p>

<hr>
<center>
<table border>
<tr bgcolor=lightblue>
<th width=80>
客户姓名
<th width=80>
收费金额
<th width=100>
收费记录员
<th width=150>
收费时间
</tr>
<%
totalPage = MoneyBean.getTotalPage(10);
try {
if (request.getParameter("Page") == null
|| request.getParameter("Page").equals(""))
pages = 1;
else
pages = Integer.parseInt(request.getParameter("Page"));
} catch (java.lang.NumberFormatException e) {
// 处理用户从浏览器地址拦直接输入pages=ab等所造成的异常
pages = 1;
}

if (pages < 1)
pages = 1;
if (pages > totalPage)
pages = totalPage;

out.println(showOnePage(rs, pages, pageSize));
%>
</table>
<form Action="seeall.jsp" method="get">
<%
if (pages != 1) {
out.println("<a href= seeall.jsp?Page=1>第一页</A>?");
out.println("<a href= seeall.jsp?Page=" + (pages - 1)
+ ">上一页</A>?");
}
if (pages != totalPage) {
out.println("<a href= seeall.jsp?Page=" + (pages + 1)
+ ">下一页</A>?");
out.println("<a href= seeall.jsp?Page=" + totalPage
+ ">最后一页</A>?");
}
rs.close();
%>
<p>
输入页数:
<input type="text" name="Page" size="3" value="<%=pages%>">
<input type="submit" value="翻页">
页数:
<font color="red"><%=pages%>/<%=totalPage%></font>
</p>
</form>
</center>
<hr>
<p align="center">
<font size="5" face="楷体_GB2312" color="#0000FF">本车场今天总收入:<font size="5" face="楷体_GB2312" color='red'><%=MoneyBean.getSum()%></font>(人民币)</font>
</p>
</body>
</html>





收费记录里面的代码部分package com.jspdev;

import java.sql.*;

import com.db.DataBaseManager;

public class MoneyBean {
public static Connection getConnection() {
Connection conn = null;
conn = DataBaseManager.getConnection();
return conn;
}

/**
 * 关闭指定的结果集
 * 
 * @param rs
 *            要关闭的结果集
 */
public static void closeResultSet(ResultSet rs) {
if (rs != null) {
try {