if rs.nextorg.apache.jasper.JasperException:An exception occurred processing JSP page /admin/Acheck.jsp at line 1613:14:String sql="select * from cqut_admin where Id='"+login+"' and Password='"+password+"'";15:ResultSet rs=con.executeQuery(sql);16:if
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 05:59:34
if rs.nextorg.apache.jasper.JasperException:An exception occurred processing JSP page /admin/Acheck.jsp at line 1613:14:String sql="select * from cqut_admin where Id='"+login+"' and Password='"+password+"'";15:ResultSet rs=con.executeQuery(sql);16:if
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,但是还是出上面的错.
if rs.nextorg.apache.jasper.JasperException:An exception occurred processing JSP page /admin/Acheck.jsp at line 1613:14:String sql="select * from cqut_admin where Id='"+login+"' and Password='"+password+"'";15:ResultSet rs=con.executeQuery(sql);16:if
是不是需要用con创建个Statement或PreparedStatement对象,再用这个对象执行executeQuery? Statement stat = con.createStatement(); ResultSet rs = stat.executeQuery(sql); 记得即使没取到数据rs也不是空来着.你的con如果是Connection的话就创建个Statement或PreparedStatement对象.最好把封装的代码也发下. 把ResultSet rs=con.executeQuery(sql);改成上面两句试过了没啊?