数据校验功能后台主要包括两个类:QTPCommonServlet.java和QTPCommonDao.java
  其中QTPCommonServlet.java为:

 

package com.runqianapp.qtp;
import  java .io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.runqianapp.qtp.QTPCommonDao;
import com.geezn.exception.GeeznException;
import com.runqianapp.common.log.GEZLoggerManager;
import com.runqianapp.common.servlet.AbstractGezServlet;
/**
*  QTP 数据检查Servlet
* @author RAQ
*
*/
public class QTPCommonServlet extends AbstractGezServlet {
/**获取表中所有数据*/
private static final String GET_ALL_DATA = "getAllData";
/**检查删除操作结果*/
private static final String CHECK_DELETE_RESULT = "checkDeleteResult";
/**
* 重写service()方法
*/
public void service(HttpServletRequest request, HttpServletResponse response){
response.setContentType("text/html");
PrintWriter out = null;
try {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
out = response.getWriter();
} catch (Exception e) {
GeeznException ge;
if(e instanceof GeeznException){
ge = (GeeznException) e;
}else{
ge = new GeeznException(QTPCommonDao.MODULE_QTP, GEZLoggerManager.LOGLEVEL_ERROR,"设置字符格式、获取输出对象时,发生错误", e, "{}");
}
out.print(ge.getErrorMessageJson());
}
String action = request.getParameter("action");
if(GET_ALL_DATA.equals(action)){
String sql = request.getParameter("sql");
String sqlDateNumber = request.getParameter("sqlDateNumber");
String allDatas = "";
try {
allDatas = QTPCommonDao.getAllDatas(sql,sqlDateNumber);
} catch (GeeznException e) {
GeeznException ge;
if(e instanceof GeeznException){
ge = (GeeznException) e;
}else{
ge = new GeeznException(QTPCommonDao.MODULE_QTP, GEZLoggerManager.LOGLEVEL_ERROR,"得到表中数据时,发生错误", e, "{}");
}
out.print(ge.getErrorMessageJson());
}
out.print(allDatas);
}else if(CHECK_DELETE_RESULT.equals(action)){
String sql = request.getParameter("sql");
boolean deleteResult = false;
try {
deleteResult = QTPCommonDao.checkDeleteResult(sql);
} catch (GeeznException e) {
GeeznException ge;
if(e instanceof GeeznException){
ge = (GeeznException) e;
}else{
ge = new GeeznException(QTPCommonDao.MODULE_QTP, GEZLoggerManager.LOGLEVEL_ERROR,"检查删除动作结果时,发生错误", e, "{}");
}
out.print(ge.getErrorMessageJson());
}
out.print(deleteResult);
}
}
}