Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
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
servlet.CountIPShw.doPost(CountIPShw.java:110)
servlet.CountIPShw.doGet(CountIPShw.java:50)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
org.apache.jsp.mng.ipcount_jsp._jspService(ipcount_jsp.java:90)
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)
[size=medium]servlet.CountIPShw.doPost(CountIPShw.java:110)[/size]代码如下:
ExecuteDB exedb = new ExecuteDB();
ResultSet rs1 = exedb.exeQuery("select count(*) from ip where date != \""+date+"\";");
ResultSet rs2 = exedb.exeQuery("select * from visit;");
ResultSet rs3 = exedb.exeQuery("select count(*) from ip where date = \""+date+"\";");
try {
[size=medium]if(rs1.next()&&rs2.next()){[/size]//这是第110行
if(rs1.getString(1)!=null&&!rs1.getString(1).equals("")){
amount = rs1.getInt(1)+rs2.getInt(1);
exedb.exeSql("update visit set amount = "+amount);
exedb.exeSql("delete from ip where date != \""+date+"\";");
}
}
rs1.close();
rs2.close();
if(rs3.next()){
if(rs3.getString(1)!=null&&!rs3.getString(1).equals(""))today = rs3.getInt(1);
}
rs3.close();
} catch (SQLException e) {
}
exedb.close();
这里的ExecuteDB 类代码如下:
package newshop;
import java.sql.*;
public class ExecuteDB
{
private String userName="****";
private String userPassword="****";
private String url="jdbc:mysql://127.0.0.1:3306/****";
private Connection dbConn;
private Statement stmt;
private ResultSet rs;
private String errMes;
public ExecuteDB()
{
dbConn = this.getConn();
stmt = null;
rs = null;
this.errMes = this.getErrMes();
}
public Connection getConn()
{
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
dbConn= DriverManager.getConnection(url,userName,userPassword);
}
catch(Exception e)
{
dbConn = null;
errMes=e.toString();
}finally{
}
return dbConn;
}
public boolean exeSql(String strSql)
{
boolean isSuc = false;
try
{
stmt=dbConn.createStatement();
stmt.executeUpdate(strSql);
isSuc = true;
}
catch(Exception e)
{
this.errMes = this.errMes + "<br>" +e.toString();
}finally{
}
return isSuc;
}
public ResultSet exeQuery(String strSql)
{
try
{
stmt=dbConn.createStatement();
rs =stmt.executeQuery(strSql);
}
catch(Exception e)
{
this.errMes = this.errMes + "<br>" +e.toString();
rs = null;
}finally{
}
return rs;
}
public void close()
{
try {
stmt.close();
dbConn.close();
} catch (SQLException e) {
this.errMes = this.errMes + "<br>" +e.toString();
}
}
public String getErrMes()
{
return errMes;
}
}