帮我看一下,这是什么错误?

yimengxiaoxin 2004-05-05 08:51:24
我的的是Acess数据库
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
.....................
root cause

java.lang.NullPointerException

--------------------------------------------------------------------------------

Apache Tomcat/4.1.18
这是登入页面:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登入</title>
<style type="text/css">
BODY { FONT-FAMILY:宋体; font-size:9pt}
TH { font-size:9pt}
td {color:#FF66FF;font-size:9pt}
</style>
</head>
<body>
<form method="post" action="confirm.jsp" >
<table align="center" border="0" cellpadding="0" width="332" bgcolor="#f0f8ff" bordercolorlight="#4da6ff" bordercolordark="#ecf5ff">
<tr>
<td colspan="2" align="center"><h4><font color="#9933FF">请登入</font></h4></td>
</tr>
<tr>
<td align="left">用  户:</td>
<td><input type="text" name="Sno"></td>
</tr>
<tr>
<td align="left">出生年月:</td>
<td ><input type="password" name="Sdate"></td>
</tr>
<tr>
<td align="left">姓名:</td>
<td><input type="password" name="Sname"></td>
</tr>
</table>
<input name="submit" type="submit" value="登入" align="middle">
</form>
</body>
</html>
这是验证页面:
<%@ page contentType="text/html;charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<head>
<title>验证页面</title>
</head>
<body bgcolor="#9999FF">
<jsp:useBean id="LoginBean" scope="request" class="jsjxpg.jsjxpg" />
<%
String number=new String(request.getParameter("Sno").getBytes("8859_1"));
String birthday=new String(request.getParameter("Sdate").getBytes("8859_1"));
String name=new String(request.getParameter("Sname").getBytes("8859_1"));
String sql="select * from studentTable where Sno='"+number+"' and Sdate='"+birthday+"'";
ResultSet rs=LoginBean.executeQuery(sql);
if (rs.next()){
rs.close();
LoginBean.closeStmt();
LoginBean.closeConn();
session.putValue("username",number);
%>
<script language="javascript">
window.location="../index.jsp?mark=登入成功"
</script>
<%}
else{
rs.close();
LoginBean.closeStmt();
LoginBean.closeConn();
String msg="登入有误";
session.putValue("Login_message",msg);
%>
<jsp:forward page="relog.jsp"/>
<%} %>
<p> </p>
</body>
</html>
这是数据库连接的javaBean
package jsjxpg;
import java.sql.*;
public class jsjxpg{
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr="jdbc:odbc:jsjxpg";
private Statement stmt=null;
private Connection conn=null;
ResultSet rs=null;
public jsjxpg(){
try{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println("jsjxpg():"+e.getMessage());
}
}
public ResultSet executeQuery(String sql){
rs=null;
try{
conn=DriverManager.getConnection(sConnStr);
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return rs;
}
public void executeUpdate(String sql){
stmt=null;
rs=null;
try{
conn=DriverManager.getConnection(sConnStr);
stmt=conn.createStatement();
stmt.executeQuery(sql);
stmt.close();
conn.close();
}
catch(SQLException ex){
System.err.println("aq.executeQuery:"+ex.getMessage());
}
}
public void closeStmt(){
try{
stmt.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
public void closeConn(){
try{
conn.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
}
怎么回出现这样一个错误:

...全文
102 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
niko_liko 2004-05-05
  • 打赏
  • 举报
回复
是不是结果集属性设置的问题?改改这个行不行:
Statement stmt=con.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
学习中....
yimengxiaoxin 2004-05-05
  • 打赏
  • 举报
回复
好象没有指向空的对象。再看看代码。是不是数据库的问题
viano 2004-05-05
  • 打赏
  • 举报
回复


指向了 空的对象!

可能事 字段 名错误, 没有要操作的字段!

或者 变量少了!

你先看看 你的 sql 语句对不对!


再看看 jsp 页面!
fuzuyuan 2004-05-05
  • 打赏
  • 举报
回复
晕,如果我没猜错的话,你数据库中的日期数据一定是日期型的,但是你在写查询语句的时候将它当做字符型处理了,将你写 的sql语句放在access数据库中试试,看是不是对的

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧