if rs.nextorg.apache.jasper.JasperException:An exception occ

le00002022-10-04 11:39:541条回答

if rs.next
org.apache.jasper.JasperException:An exception occurred processing JSP page /admin/Acheck.jsp at line 16
13:
14:String sql="select * from cqut_admin where Id='"+login+"' and Password='"+password+"'";
15:ResultSet rs=con.executeQuery(sql);
16:if(rs.next()){
17:session.setAttribute("login",login);
18:response.sendRedirect("index.htm");
19:}else{
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NullPointerException
org.apache.jsp.admin.Acheck_jsp._jspService(Acheck_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
空指针异常?怎么解决呢?
----------是不是需要用con创建个Statement或PreparedStatement对象,再用这个对象执行executeQuery?
package com.bwm.db;
import java.sql.*;
public class Condb{
String servername="localhost";
String drivername="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url="jdbc:microsoft:sqlserver://servername:1433;DatabaseName=cqut;user=sa;password=123;";
Connection con=null;
ResultSet rs=null;
public Condb(){ //数据库连接
try{
Class.forName(drivername);
}catch(java.lang.ClassNotFoundException e){
System.err.println(e.getMessage());
}
}
这只是个连接的代码,太多发不起!
import 了该bean,但是还是出上面的错.

已提交,审核后显示!提交回复

共1条回复
云的投影1126 共回答了22个问题 | 采纳率90.9%
是不是需要用con创建个Statement或PreparedStatement对象,再用这个对象执行executeQuery? Statement stat = con.createStatement(); ResultSet rs = stat.executeQuery(sql); 记得即使没取到数据rs也不是空来着.你的con如果是Connection的话就创建个Statement或PreparedStatement对象.最好把封装的代码也发下. 把ResultSet rs=con.executeQuery(sql);改成上面两句试过了没啊?
1年前

相关推荐

英语翻译TheApache mission computer is “ABC–anything but COTS,”前边
英语翻译
TheApache mission computer is “ABC–anything but COTS,”
前边是阿帕奇任务计算机后边COTS是个设备类似芯片,主要是ABC-anything but
lshd77771年前1
xyxiaofeng 共回答了15个问题 | 采纳率93.3%
The Apache mission computer is “ABC–anything but COTS,”
Apache 牌任务电脑是初学者的选择,可以做到任何事情但是花销大.
Tomcat问题the Apache Tomcai Native library which allows optima
Tomcat问题the Apache Tomcai Native library which allows optimal performance in product.
你怎么解决的啊?求救
皮331年前2
fanjunlawyer 共回答了12个问题 | 采纳率100%
the Apache Tomcai Native library which allows optimal performance in 你没有配tomcat的jdk.如果不是,看你配的jdk环境变量对不对.这两个的
英语翻译Failure of server APACHE bridge:cannot write 1440 bytes
英语翻译
Failure of server APACHE bridge:cannot write 1440 bytes to tmp file /tmp/_wl_proxy/_post_24523_0 Build date/time:Apr 18 2009 11:46:48 Change Number:1211636 Failure of server APACHE bridge:Internal Server failure,APACHE plugin.Cannot continue.Build date/time:Apr 18 2009 11:46:48 Change Number:1211636
管风急1年前3
pengnian825 共回答了15个问题 | 采纳率93.3%
APACHE服务器网桥错误:无法给 tmp file /tmp/_wl_proxy/_post_24523_0写入1440个字节,数据建立的时间:2009年4月18日 11:46:48 更改的数字:1211636
APACHE服务器网桥错误:服务器内部故障,APACHE plugin 不能继续,数据建立的时间:2009年4月18日 11:46:48 更改的数字:1211636 (不太懂,仅供参考)
在log4j中,log4j.addivity.org.apache=true这句话什么意思?
在log4j中,log4j.addivity.org.apache=true这句话什么意思?
log4j.addivity.org.apache=true这句话什么意思?
emailguanggao1年前1
DIY_aqiong 共回答了28个问题 | 采纳率82.1%
是否追加写入
ant环境变量配置我已经配置了ANT_HOME=D:\apache-ant-1.7.0Path=D:\apache-an
ant环境变量配置
我已经配置了ANT_HOME=D:apache-ant-1.7.0
Path=D:apache-ant-1.7.0bin
为什么cmd 输入act-ersion 还是出现‘ant-version’不是内部或外部命令,也不是可运行的程序?
willczrw1年前1
shirley_sj 共回答了14个问题 | 采纳率78.6%
ant -version 注意空格
设定环境变量后.注意重新打开cmd
英语翻译Please close this command only for Shutdown Apache 2 is
英语翻译
Please close this command only for Shutdown Apache 2 is running,don not close this window.
天呀0砸谈1年前6
陈东 共回答了13个问题 | 采纳率100%
当只有 “正在关闭Apache 2”正在运行时 请关闭这个指令.不要关闭这个窗口.