请教 jsp连接SQL server 2000 出现了这问题 怎么解决

来源:百度知道 编辑:UC知道 时间:2024/06/07 11:46:45
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:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException
org.apache.jsp.buju3_jsp._jspService(org.apache.jsp.buju3_jsp:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.htt

这是一个空指针异常:java.lang.NullPointerException
对你的代码稍微改了下:
<%
Connection con = null ;
Statement stmt = null ;
ResultSet rst = null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=xsxxglxx";
String user = "sa";
String password = "";
con = DriverManager.getConnection(url,user,password);
if(con==null)
{
System.out.println("Connection对象为空!");
}
stmt = con.createStatement();
String sql = "select * from glyxxb";
rst = stmt.executeQuery(sql);
if(rst==null)
{
System.out.println("ResultSet为空!");
}
while(rst.next()){%>
<%=rst.getString("glyID")%>
<%}
}catch(SQLException e){System.out.print(e.getMessage());}
finally{rst.close();stmt.close();}
%>
<