java.lang.ClassCastException java.sql.Timestamp cannot be cast to java.lang.String

修改前:

System.out.println("sj:"+(String)queryBySql(

                                     "selectendsaletime from lot_gamepara p,lot_game g where p.gaid=g.gaid and issue=? andposcode=?",

                                     issue,gamename));

 

出现异常如下:

2012-7-10 16:08:56org.apache.catalina.core.StandardWrapperValve invoke

严重:Servlet.service() for servlet LotteryServlet threw exception

java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.lang.String

    atcom.lottery.dao.LotteryDao.getEndtime(LotteryDao.java:57)

    atcom.lottery.service.lottery.RePrintService.authentication(RePrintService.java:61)

    atcom.lottery.service.lottery.RePrintService.getRes(RePrintService.java:36)

    atcom.lottery.servlet.LotteryServlet.doMsg00(LotteryServlet.java:247)

    atcom.lottery.servlet.LotteryServlet.doPost(LotteryServlet.java:74)

    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:637)

    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

    atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

    atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

    atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

    atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

    atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

    atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)

    atorg.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)

    atorg.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)

    atorg.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)

    atjava.lang.Thread.run(Thread.java:662)

 

修改后:

System.out.println("sj:"+ queryBySql(

                                     "selectendsaletime from lot_gamepara p,lot_game g where p.gaid=g.gaid and issue=? andposcode=?",

                                     issue,gamename).toString());

 


你可能感兴趣的:(servlet,String)