if rs.nextorg.apache.jasper.JasperException:An exception occ
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/11/08 04:51:55
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,但是还是出上面的错.
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,但是还是出上面的错.
是不是需要用con创建个Statement或PreparedStatement对象,再用这个对象执行executeQuery? Statement stat = con.createStatement(); ResultSet rs = stat.executeQuery(sql); 记得即使没取到数据rs也不是空来着.你的con如果是Connection的话就创建个Statement或PreparedStatement对象.最好把封装的代码也发下. 把ResultSet rs=con.executeQuery(sql);改成上面两句试过了没啊?
if rs.nextorg.apache.jasper.JasperException:An exception occ
org.apache.jasper.JasperException:An exception occurred proc
org.apache.jasper.JasperException:/taskallot.jsp(4,17) quote
org.apache.jasper.JasperException:Unable to compile class fo
if not rs.eof
If Not (rs.BOF And rs.
翻译一下! Unhandled Exception An unhandled exception was thrown
IF Not Rs.Bof [asp]
The underlying connection was closed:An unexpected error occ
An internal exception occuredAddress:Ox7c93366cpiease,contac
make an exception in our case
if rs.eof or rs.bof then 和if rs.eof and rs.bof 它们一样不?