出现了一个错误我想很少人能够解决??

boyandgirl 2001-11-15 03:02:25
java.lang.NullPointerException
at jrun__regedit2ejspc._jspService(jrun__regedit2ejspc.java:80)
at allaire.jrun.jsp.HttpJSPServlet.service(../jsp/HttpJSPServlet.java:39)
at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:228)
at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:196)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1416)
at allaire.jrun.session.JRunSessionService.service(../session/JRunSessionService.java:1082)
at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1270)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:89)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1552)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1542)
at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:364)
at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:115)
at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
...全文
117 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
boyandgirl 2001-11-15
  • 打赏
  • 举报
回复
楼上兄弟们,到底我该听那个人的话啦,我现在正是弄不动了。
在这里用stmt.executeQuery(sql); 这样可以吗,应该可以的吧!!
还有为什么一定要添加到session对象当中取那,能够给我个理由香吗,
我那个程序,你们有没有调试通过拉。
对了我在解程序的时候经常会碰到
java.lang.NullPointerException】
这个东西一般是什么错误呢?能够给我说说吗??
wendaoyuan 2001-11-15
  • 打赏
  • 举报
回复
insert,update,delete操作应该用executeUpdate()方法
即将stmt.executeQuery(sql); 改为stmt.executeUpdate(sql);就可以了
linfei 2001-11-15
  • 打赏
  • 举报
回复
他的语句里有这样的句子嘛
happynet 2001-11-15
  • 打赏
  • 举报
回复
linfei(林飞)你真细心呀!呵呵!

除了添加入INTO外,还有一点,
就是加入:
conn=DriverManager.getConnection(SCon);
Statement stmt=conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(sql);

if(rs.next())
{
//把用户的注册名写到session对象当中去
session.putValue("字段2",uname);
}
这样就能通过了!呵呵!给分!呵呵!
linfei 2001-11-15
  • 打赏
  • 举报
回复
记得在insert后接into,记得以前编asp时,插入sql server不用加into,别的还是要加的。
再就是insert语句返回的是整形数据,将rs=stmt.executeQuery(sql);改成stmt.executeQuery(sql);
另外,请确认表达传递过来的数据的名称没有弄错以及与数据库的字段类型相匹配。
我试过你的语句,将前两点改正后,操作成功!
boyandgirl 2001-11-15
  • 打赏
  • 举报
回复
就是下面的这个程序,帮我看看
<%@page language="java" import="java.sql.*"%>
<%@page contentType="text/html;charset=gb2312"%>
<!--接下来的程序是从表单获取数据-->
<%
String uid=request.getParameter("uid");
String uname=request.getParameter("uname");
String ugid=request.getParameter("ugid");
String upwd=request.getParameter("upwd");
//生成注册用的sql语句
String sql="insert sysuser(字段1,字段2,字段3,字段4) values('"+uid+"','"+uname+"','"+ugid+"','"+upwd+"')";
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String SCon="jdbc:odbc:db1";
Connection conn=null;
ResultSet rs=null;
try {
Class.forName(sDBDriver);
}
//异常处理
catch(java.lang.ClassNotFoundException e){
}

//定义sql查询语句
try{
conn=DriverManager.getConnection(SCon);
Statement stmt=conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(sql);
}
//异常处理
catch(SQLException ex){
System.err.println("aq.executeQuery():"+ex.getMessage());
}

//把用户的注册名写到session对象当中去
session.putValue("字段2",uname);
%>
happynet 2001-11-15
  • 打赏
  • 举报
回复
就看这个能解决么?那就厉害啦!呵呵!你至少也要给点程序出来啦!

81,122

社区成员

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

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