| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 491 人关注过本帖
标题:[求助]JSP程序出错
只看楼主 加入收藏
chenyi47240447
Rank: 1
等 级:新手上路
帖 子:170
专家分:0
注 册:2006-8-3
收藏
 问题点数:0 回复次数:0 
[求助]JSP程序出错

<%@ page contentType="text/html; charset=GB2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%!
public class sql_data{
String sDBDriver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String sUrl="jdbc:microsoft:sqlserver://192.168.1.107:1433;DatabaseName=pubs;user=sa;password=119";
Connection conn=null;
ResultSet rs=null;
public sql_data(){
try{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println("sql_data():"+e.getMessage());
}
}
public void eInsert(String sql){
try{
conn=DriverManager.getConnection(sUrl);
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex){
System.err.println("sql_data.executeUpdate:"+ex.getMessage());
}
}
public ResultSet eQuery(String sql){
rs=null;
try{
conn=java.sql.DriverManager.getConnection(sUrl);
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println("sql_data.executeQuery:"+ex.getMessage());
}
return rs;
}
public void eDelete(String sql){
try{
conn=DriverManager.getConnection(sUrl);
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex){
System.err.println("sql_data.executeDelete:"+ex.getMessage());
}
}
}
%>
<%
String sql="select * from student";
sql_data dbc=new sql_data();
ResultSet rs = dbc.eQuery(sql);
%>
<%

out.print("<Table Border>");
out.print("<TR>");
out.print("<TH width=100>"+"学号");
out.print("<TH width=100>"+"姓名");
out.print("<TH width=50>"+"数学成绩");
out.print("<TH width=50>"+"英语成绩");
out.print("<TH width=50>"+"物理成绩");
out.print("</TR>");
while(rs.next())
{ out.print("<TR>");
out.print("<TD>"+rs.getString(1)+"</TD>");
out.print("<TD>"+rs.getString(2)+"</TD>");
out.print("<TD>"+rs.getInt("数学成绩")+"</TD>");
out.print("<TD>"+rs.getInt("英语成绩")+"</TD>");
out.print("<TD>"+rs.getInt("物理成绩")+"</TD>");
out.print("</TR>");
}
out.print("</Table>");
%>
</body>
</html>
浏览报的错是:
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.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NullPointerException
org.apache.jsp.Example5_005f1_jsp._jspService(Example5_005f1_jsp.java:114)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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

搜索更多相关主题的帖子: JSP 
2006-08-03 10:45
快速回复:[求助]JSP程序出错
数据加载中...
 
   



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

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