通过线程
public void run() {
System.out.println("ProcessThread running...");
while(!stop){
System.out.println("ProcessThread updating today's counter["+new Date()+"]...");
WebApplicationContext cxt = WebApplicationContextUtils.getWebApplicationContext(this.context);

StatService statSev = (StatService)cxt.getBean("statSev");

System.out.println("Updating order & canel counter...");
//statSev.updateOrderToday();

System.out.println("Updating pv&uv counter...");
statSev.updatePVCountDoday();

System.out.println("Updating cpstat counter...");
statSev.updateCpCountDoday();

try{
Thread.sleep(10*60*1000);
}catch(InterruptedException e){
e.printStackTrace();
}
}
}
该线程有3个针对数据库的操作 
这个是上面的statSev.updateCpCountDoday();
public void updateCpCountDoday() {

Collection types = this.getTypes();
Iterator it = types.iterator();
while (it.hasNext()) {
typeBean typelist = (typeBean) it.next();
cpCountBean fw = statDao.findFwCpCountBean(typelist.getCode(),contextpath,fwservletpath,begin,end);
cpCountBean jf = statDao.findJfCpCountBean(typelist.getCode(),contextpath,jfservletpath,begin,end);
statDao.updateCpCount(typelist.getCode(),begin,end,fw.getFwcount(),jf.getJfcount(),jf.getJfnums());
}
}下面是updateCpCount
public void updateCpCount(String typeId,long begin,long end,long fwcount,long jfcount,long jfnums){
String sqlStr1 = "select count(ID) from STAT_CP where TYPEID=? and BEGINTIME=? and ENDTIME=?";
String sqlStr2 = "insert into STAT_CP (TYPEID,BEGINTIME,ENDTIME,FWCOUNT,JFCOUNT,JFNUMS) values (?,?,?,?,?,?)";
String sqlStr3 = "update STAT_CP set FWCOUNT=?,JFCOUNT=?,JFNUMS=? where TYPEID=? and BEGINTIME=? and ENDTIME=?";

Object[] param1 = new Object[3];
param1[0] = typeId;
param1[1] = new Long(begin);
param1[2] = new Long(end);

Object[] param2 = new Object[6];
param2[0] = typeId;
param2[1] = new Long(begin);
param2[2] = new Long(end);
param2[3] = new Long(fwcount);
param2[4] = new Long(jfcount);
param2[5] = new Long(jfnums);
System.out.println(new java.sql.Timestamp(begin));
System.out.println(new java.sql.Timestamp(end));
Object[] param3 = new Object[6];
param3[0] = new Long(fwcount);
param3[1] = new Long(jfcount);
param3[2] = new Long(jfnums);
param3[3] = typeId;
param3[4] = new Long(begin);
param3[5] = new Long(end);
JdbcTemplate templ = new JdbcTemplate(this.getDataSource());
//System.out.println(templ.queryForInt(sqlStr1,param1));
if(templ.queryForInt(sqlStr1,param1) == 0){
templ.update(sqlStr2,param2);
}
else{
templ.update(sqlStr3,param3);
}
} tomcat启动后该线程开始运行,每隔10分钟会对STAT_CP这个表进行更新,事务控制由spring本身org.springframework.transaction.interceptor.TransactionProxyFactoryBean管理,通过配置文件配置,但在运行过程中经常会出现 Could not reset JDBC connection after java.sql.SQLException: Io 异常: Connection reset by peer: socket write error的错误,请大家帮我看看什么原因,多谢了!!!!!!!!!!!!!!!!!  tomcat5.0