我的数据库不知道怎么回事,可以正常查找和备份什么的,就是连不上JSP,希望哪位大虾可以帮帮我,小弟在这里先谢谢了,这个是我的源代码
<%@page contentType="text/html;charset=GBK"%>
<%@page import="java.sql.*"%>
<%
//1.加载 数据库 驱动
String DBDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
try
{
Class.forName(DBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
out.println("ROOT/WEB-INF/lib下没有 驱动");
}
//2.建立连接
Connection conn = null;
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=zgqcw";
String user = "zgqcw";
String password = "zgqcw";
try
{
conn = DriverManager.getConnection(url,user,password);
}
catch(SQLException e)
{
out.println("没连上");
}
//3.生成 sql表述执行对象----相当于:查询分析器
Statement stmt = null;
try
{
stmt = conn.createStatement();
}
catch(SQLException e)
{
out.println("没有生成 SQL表述执行对象");
}
//4.执行SQL
String sql="select changshang_id,changshang_ming "
+" from dbo.cs_changshang";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next() ==true)
{
%>
<li>
<%=rs.getInt("changshang_id")%>
<%=rs.getString("changshang_ming")%>
<%
}
%>
一运行就提示:
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:370)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
org.apache.jsp._11_jsp._jspService(org.apache.jsp._11_jsp:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.11 logs.
Apache Tomcat/5.5.11