救救小弟吧

AwaysOnline 2009-10-12 12:16:19
<%@ page contentType="text/html;charset=gb2312" language="java" %>
<%@ page import="java.sql.*" %>
<html>
<head> <title>用户名验证 </title> </head>
<%
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
//String strUser=request.getParameter("user");
//String strPass=request.getParameter("pass");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String strConn="jdbc:odbc:data";
conn=DriverManager.getConnection(strConn);
stmt=conn.createStatement();
}
catch(Exception e)
{
out.println(e.toString());
}
String strSql="select ID,Password from table1 ";
rs=stmt.executeQuery(strSql);
while(rs.next())
{ %>
<%=rs.getString(1)%>
<%=rs.getString(2)%>
<% } %>
<%
rs.close();
stmt.close();
conn.close();
%>
</html>


运行的时候总是提示
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.NullPointerException
org.apache.jsp._4_jsp._jspService(_4_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


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

到底怎么回事,我都改了好多次了。
...全文
122 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
AwaysOnline 2009-10-13
  • 打赏
  • 举报
回复
是啊!可是我有数据源啊(data),,没错啊,这个程序在我同学的电脑上都可以运行,在我这边就出现这个问题了
aixilin520 2009-10-13
  • 打赏
  • 举报
回复
你用ODBC连SQL 要用数据源啊
在控制面板 -管理工具-数据源

然后填加一个名字为data的 数据源 指定到你的数据库中去

这个data 是跟你 String strConn="jdbc:odbc:data";

对应的
swandragon 2009-10-12
  • 打赏
  • 举报
回复
java.lang.NullPointerException
org.apache.jsp._4_jsp._jspService(_4_jsp.java:77)
NullPointerException

检查一下哪个对象是null的对象
jisg_57 2009-10-12
  • 打赏
  • 举报
回复
空指针问题,看看哪个不能为空的变量值为空了
AwaysOnline 2009-10-12
  • 打赏
  • 举报
回复
还是不懂???
AwaysOnline 2009-10-12
  • 打赏
  • 举报
回复
数据源名字是data啊,还有什么名字吗:
aixilin520 2009-10-12
  • 打赏
  • 举报
回复
你有没有配 名字 为 data的数据源啊

81,094

社区成员

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

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