日期:2014-05-16  浏览次数:20512 次

绝对难题,tomcat警告 spring jdbcTemplate查询
我的开发环境是:jdk1.5+tomcat5.5+eclipse+sqlserver,开发语言struts+spring
代码:
    public List getResultsFormDate(String dateStart, String dateEnd) {
        return  getJdbcTemplate().queryForList("select * from kfb_result where create_time between '"+dateStart+"' and '"+dateEnd+"' order by create_time desc");
    }

点击查询后,页面可以显示数据列表,任何问题都没有。

但 tomcat 却报错

Caused by: java.net.SocketException: Connection reset by peer: socket write error
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:746)
        at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:433)
        at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:304)
        at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:991)
        at org.apache.coyote.Response.action(Response.java:182)
        at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:322)
        ... 13 more
2007-11-25 19:20:55 org.apache.catalina.core.StandardHostValve status
警告: Exception Processing ErrorPage[errorCode=404, location=/404.jsp]
ClientAbortException:  java.net.SocketException: Connection reset by peer: socket write error
        at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:327)
        at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:293)
        at org.apache.catalina.connector.Response.flushBuffer(Response.java:537)
        at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:286)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)

这究竟是什么原因呢???


如果把上面的SQL语句换成select * from kfb_result,或者根据其它字段查询,就一点事都没有。

为什么根据日期来查询,tomcat就会警告呢??页面是显示正常,也能正常地查出结果。