标题:[求助] 帮忙看看这个错误大概是什么意思??
只看楼主
梧桐
Rank: 1
等 级:新手上路
帖 子:135
专家分:0
注 册:2005-11-17
 问题点数:0 回复次数:24 
[求助] 帮忙看看这个错误大概是什么意思??


偶是新手,刚看了点JSP的书
在测试数据库的时候出了这么一个错误信息,我实在看不懂错误是什么意思!!

有经验的朋友帮忙看看!!

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: Exception in JSP: /dbprogram.jsp:52

49: out.println("恭喜,表连接创建成功!");
50: %>
51:
52: <%
53: ResultSet RS= Stmt.executeQuery("SELECT * FROM EMPLOYEE WHERE eage<25"); /*连接到数据库中的表EMPLOYEE上*/
54: String tt; /**号表示选择表中所有的列*/
55: String link; /*若选择其中的某几列可以将*号换成列标号*/


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NullPointerException
org.apache.jsp.dbprogram_jsp._jspService(dbprogram_jsp.java:104)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.


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

Apache Tomcat/5.5.23

搜索更多相关主题的帖子: 数据库 Exception The JSP 
2007-03-18 22:52
angeloc
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:36
帖 子:1353
专家分:0
注 册:2006-11-21
得分:0 
没代码,看不懂!

老牛明知夕阳晚,不用扬鞭自奋蹄; Angelo\'s BLOG
2007-03-19 00:13
风月_无边
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:60
帖 子:2959
专家分:652
注 册:2007-1-19
得分:0 

好像是有空指针异常,看看连接有没有问题!!


我的网站 http://www.
2007-03-19 08:16
angeloc
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:36
帖 子:1353
专家分:0
注 册:2006-11-21
得分:0 
不是好象,就是!!!不过没代码哪能找到错误!

老牛明知夕阳晚,不用扬鞭自奋蹄; Angelo\'s BLOG
2007-03-19 08:56
梧桐
Rank: 1
等 级:新手上路
帖 子:135
专家分:0
注 册:2005-11-17
得分:0 

谢谢各位!!
我没发现有空指针异常在程序哪个地方??
帮忙看一下
下面是代码:

<%@ page contentType="text/html; charset=gb2312" %>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<!--导入结束-->
<html>
<head>
<title>数据库连接实验</title>
</head>
<body>
<%
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:try";//“try”的意思就是与刚才设置的数据源名对应;
Connection Con = null;
Statement Stmt = null;
try
{
try /*加载驱动程序*/
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
out.print("Connect to Database error: " + e.getMessage());
}
try /*建立连接*/
{
Con = DriverManager.getConnection(sConnStr,"sa","");
}
catch(SQLException e)
{
out.print(e.toString());
}

Stmt = Con.createStatement(); /*创建JDBC声明*/
String query="CREATE TABLE GUEST" + /*在数据库中创建新的表*/
"(NUM VARCHAR(32),"+
"USERNAME TEXT,"+
"CONTENT TEXT,"+
"PASSWORD INTEGER,"+
"TOTAL INTEGER,"+
"REALNAME TEXT)";
Stmt.executeUpdate(query); /*更新数据库*/
}
catch (Exception e) {}
out.println("恭喜,表连接创建成功!");
%>

<%
ResultSet RS= Stmt.executeQuery("SELECT * FROM EMPLOYEE WHERE eage<25"); /*连接到数据库中的表EMPLOYEE上*/
String tt; /**号表示选择表中所有的列*/
String link; /*若选择其中的某几列可以将*号换成列标号*/
String makeStr; /*WHERE语句表示条件选择*/
out.print("<table border=2 style=color:blue >");
while (RS.next()) {
out.print("<tr><td>");
tt = RS.getString("ename"); /*查询表中NUM字段的内容,字段内容可能使数组,默认列输出*/
out.print(tt);
out.print("</td><td>");
tt = RS.getString("esex");
out.print(tt);
out.print("</td><td>");
tt = RS.getString("eage");
out.print(tt);
out.print("</td><td>");
tt=RS.getString("egrade");
out.print(tt);
out.print("</td><td>");
}
out.print("</table>");
RS.close();
out.println("数据查询成功!");
%>

<% /*在数据库中添加数据*/
String sql="INSERT INTO EMPLOYEE VALUES ('5','aaa','m',54,'hehe')";
Stmt.executeUpdate(sql);
out.println("添加数据成功!");
%>
</body>
</html>


The future is ours to build!
2007-03-19 09:36
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 
Exception in JSP: /dbprogram.jsp:52

这个代码的第52行

你自己看看是什么

可惜不是你,陪我到最后
2007-03-19 09:38
梧桐
Rank: 1
等 级:新手上路
帖 子:135
专家分:0
注 册:2005-11-17
得分:0 

 代码52行是红色的部分,我还是没看懂是什么问题

<%@ page contentType="text/html; charset=gb2312" %>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<!--导入结束-->
<html>
<head>
<title>数据库连接实验</title>
</head>
<body>
<%
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:try";//“try”的意思就是与刚才设置的数据源名对应;
Connection Con = null;
Statement Stmt = null;
try
{
try /*加载驱动程序*/
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
out.print("Connect to Database error: " + e.getMessage());
}
try /*建立连接*/
{
Con = DriverManager.getConnection(sConnStr,"sa","");
}
catch(SQLException e)
{
out.print(e.toString());
}

Stmt = Con.createStatement(); /*创建JDBC声明*/
String query="CREATE TABLE GUEST" + /*在数据库中创建新的表*/
"(NUM VARCHAR(32),"+
"USERNAME TEXT,"+
"CONTENT TEXT,"+
"PASSWORD INTEGER,"+
"TOTAL INTEGER,"+
"REALNAME TEXT)";
Stmt.executeUpdate(query); /*更新数据库*/
}
catch (Exception e) {}
out.println("恭喜,表连接创建成功!");
%>

<%
ResultSet RS= Stmt.executeQuery("SELECT * FROM EMPLOYEE WHERE eage<25"); /*连接到数据库中的表EMPLOYEE上*/

String tt; /**号表示选择表中所有的列*/
String link; /*若选择其中的某几列可以将*号换成列标号*/
String makeStr; /*WHERE语句表示条件选择*/
out.print("<table border=2 style=color:blue >");
while (RS.next()) {
out.print("<tr><td>");
tt = RS.getString("ename"); /*查询表中NUM字段的内容,字段内容可能使数组,默认列输出*/
out.print(tt);
out.print("</td><td>");
tt = RS.getString("esex");
out.print(tt);
out.print("</td><td>");
tt = RS.getString("eage");
out.print(tt);
out.print("</td><td>");
tt=RS.getString("egrade");
out.print(tt);
out.print("</td><td>");
}
out.print("</table>");
RS.close();
out.println("数据查询成功!");
%>

<% /*在数据库中添加数据*/
String sql="INSERT INTO EMPLOYEE VALUES ('5','aaa','m',54,'hehe')";
Stmt.executeUpdate(sql);
out.println("添加数据成功!");
%>
</body>
</html>


The future is ours to build!
2007-03-19 09:55
支离破碎
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:737
专家分:0
注 册:2007-1-4
得分:0 
ResultSet RS= Stmt.executeQuery("SELECT * FROM EMPLOYEE WHERE eage<25");
先确保你的stmt对象是否已存在,否则他是个NULL值。你先看看你上面的Stmt = Con.createStatement()是否建立

人生漂泊無依,有如浮萍菱花,隨水飄流,你会在我这里停留吗?
[url=http://51mynet.]http://51mynet.[/url]
2007-03-19 10:27
梧桐
Rank: 1
等 级:新手上路
帖 子:135
专家分:0
注 册:2005-11-17
得分:0 

谢谢!
真的有点烦!!
我把数据库的设置改了一下!配置数据源的时候采用的是Windows身份认证了
Con = DriverManager.getConnection(sConnStr,"sa",""); 也改为了
Con = DriverManager.getConnection(sConnStr);


改后的代码如下:

<%@ page contentType="text/html; charset=gb2312" %>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<!--导入结束-->
<html>
<head>
<title>数据库连接实验</title>
</head>
<body>
<%
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:try";//“try”的意思就是与刚才设置的数据源名对应;
Connection Con = null;
Statement Stmt = null;
try
{
try /*加载驱动程序*/
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
out.print("Connect to Database error: " + e.getMessage());
}
try /*建立连接*/
{
Con = DriverManager.getConnection(sConnStr); /*代码修改的地方*/
}
catch(SQLException e)
{
out.print(e.toString());
}

Stmt = Con.createStatement(); /*创建JDBC声明*/
String query="CREATE TABLE GUEST" + /*在数据库中创建新的表*/
"(NUM VARCHAR(32),"+
"USERNAME TEXT,"+
"CONTENT TEXT,"+
"PASSWORD INTEGER,"+
"TOTAL INTEGER,"+
"REALNAME TEXT)";
Stmt.executeUpdate(query); /*更新数据库*/
}
catch (Exception e) {}
out.println("恭喜,表连接创建成功!");
%>

<%
ResultSet RS= Stmt.executeQuery("SELECT * FROM EMPLOYEE WHERE eage<25"); /*连接到数据库中的表EMPLOYEE上*/
String tt; /**号表示选择表中所有的列*/
String link; /*若选择其中的某几列可以将*号换成列标号*/
String makeStr; /*WHERE语句表示条件选择*/
out.print("<table border=2 style=color:blue >");
while (RS.next()) {
out.print("<tr><td>");
tt = RS.getString("ename"); /*查询表中NUM字段的内容,字段内容可能使数组,默认列输出*/
out.print(tt);
out.print("</td><td>");
tt = RS.getString("esex");
out.print(tt);
out.print("</td><td>");
tt = RS.getString("eage");
out.print(tt);
out.print("</td><td>");
tt=RS.getString("egrade");
out.print(tt);
out.print("</td><td>");
}
out.print("</table>");
RS.close();
out.println("数据查询成功!");
%>

<% /*在数据库中添加数据*/
String sql="INSERT INTO EMPLOYEE VALUES ('5','aaa','m',54,'hehe')";
Stmt.executeUpdate(sql);
out.println("添加数据成功!");
%>
</body>
</html>


现在出的错误变成这样的了:

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
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NullPointerException
org.apache.jsp.dbprogram_jsp._jspService(dbprogram_jsp.java:104)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.


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

Apache Tomcat/5.5.23


劳驾帮忙看看这错误又是什么意思呢???  还是空指针??
如果是空指针,那又是哪行代码了呢??


The future is ours to build!
2007-03-19 11:09
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 
还是空指针异常,其实空指针异常是最好排除的,无非就是保证你所用到的对象都不是null就可以了

你可以在你每生成一个对象的时候,用System.out.println来输出一下,看看它是不是 null的就知道在那里哪个对象被赋了null了

可惜不是你,陪我到最后
2007-03-19 13:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-125051-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.264477 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved