调试第5章的源码时中文字符查询出现异常

wyl8927 05-12-19

banq:你好!
我在调试第5章的源码时,struts的中文乱码问题已解决,在调试searchcustomer By customer_id 时,运行正常;但在调试searchcustomer By firstName 时,数据库表中firstName为英文字符则查询运行正常,表中firstName为中文字符则查询出现异常,请问是不是字码转换出现异常的原因?如何解决?另附log 信息如下:

2005-12-19 22:09:37,104 DEBUG [com.jg.dingyue2.ejb.CustomerManagerBean] looking for firstName = 王
2005-12-19 22:09:37,104 DEBUG [com.jg.dingyue2.ejb.CustomerManagerBean] firstName.getBytes= [B@1f33bb0
2005-12-19 22:09:37,104 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.CustomerLocal#findByFN] Executing SQL: SELECT t0_s.id FROM customer t0_s WHERE (t0_s.firstName = ?)
2005-12-19 22:09:37,151 WARN [com.jg.dingyue2.ejb.CustomerManagerBean] javax.ejb.ObjectNotFoundException: No such entity!
2005-12-19 22:09:37,167 INFO [STDOUT] 05-12-19 22:09:37 [Debug:com.jdon.bussinessproxy.web.session.HttpSessionProxy:Verbose]
2005-12-19 22:09:37,167 INFO [STDOUT] Invoked Successfully : getCustomerByFN
2005-12-19 22:09:37,167 INFO [STDOUT] java.lang.NullPointerException
2005-12-19 22:09:37,167 INFO [STDOUT] at com.jg.dingyue2.web.SearchCustomerAction.findByKey(SearchCustomerAction.java:42)
2005-12-19 22:09:37,167 INFO [STDOUT] at com.jg.strutsutil.ModelViewAction.execute(ModelViewAction.java:66)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
2005-12-19 22:09:37,167 INFO [STDOUT] at com.jg.MyActionServlet.process(MyActionServlet.java:12)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
2005-12-19 22:09:37,167 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
2005-12-19 22:09:37,167 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2005-12-19 22:09:37,167 INFO [STDOUT] at com.jg.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:54)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:147)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:53)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:743)
2005-12-19 22:09:37,167 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
2005-12-19 22:09:37,182 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
2005-12-19 22:09:37,182 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)


banq
2005-12-20 09:29

>javax.ejb.ObjectNotFoundException: No such entity
已经查询数据库,只是没有查询到,和你的java系统中文编码有关,最好java和数据库都统一成UTF-8