【原创】DB2数据库乱码造成启动Tomcat5.5加载数据抛出异常!-已经解决

[size=medium][b]从DB2服务器导出文本数据导入本机,启动Tomcat5.5报错大概日志如下[/b]:[/size]org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.ID as ID9_0_, this_.PARENTID as PARENTID9_0_, this_.CODE as CODE9_0_, this_.REMARK as REMARK9_0_, this_.CODE_DICT as CODE5_9_0_, this_.SORTINDEX as SORTINDEX9_0_, this_.NAME as NAME9_0_, this_.ADDITIONAL_CTRL as ADDITIONAL8_9_0_, this_.VALID_FLAG as VALID9_9_0_, this_.DISPLAY_FLAG as DISPLAY10_9_0_ from SYS_DICTIONARY this_ order by this_.SORTINDEX asc]; SQL state [null]; error code [-99999]; null; nested exception is com.ibm.db2.jcc.c.SqlException
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bdcAccnReportQueryService' defined in URL [file:/E:/software/Tomcat5.5/webapps/cim/WEB-INF/classes/module/base/spring-service-info.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'noTranBatcher' defined in URL [file:/E:/software/Tomcat5.5/webapps/cim/WEB-INF/classes/module/base/spring-service-info.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysDictionaryService' defined in URL [file:/E:/software/Tomcat5.5/webapps/cim/WEB-INF/classes/module/base/spring-service-info.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.ID as ID9_0_, this_.PARENTID as PARENTID9_0_, this_.CODE as CODE9_0_, this_.REMARK as REMARK9_0_, this_.CODE_DICT as CODE5_9_0_, this_.SORTINDEX as SORTINDEX9_0_, this_.NAME as NAME9_0_, this_.ADDITIONAL_CTRL as ADDITIONAL8_9_0_, this_.VALID_FLAG as VALID9_9_0_, this_.DISPLAY_FLAG as DISPLAY10_9_0_ from SYS_DICTIONARY this_ order by this_.SORTINDEX asc]; SQL state [null]; error code [-99999]; null; nested exception is com.ibm.db2.jcc.c.SqlException
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'noTranBatcher' defined in URL [file:/E:/software/Tomcat5.5/webapps/cim/WEB-INF/classes/module/base/spring-service-info.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysDictionaryService' defined in URL [file:/E:/software/Tomcat5.5/webapps/cim/WEB-INF/classes/module/base/spring-service-info.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.ID as ID9_0_, this_.PARENTID as PARENTID9_0_, this_.CODE as CODE9_0_, this_.REMARK as REMARK9_0_, this_.CODE_DICT as CODE5_9_0_, this_.SORTINDEX as SORTINDEX9_0_, this_.NAME as NAME9_0_, this_.ADDITIONAL_CTRL as ADDITIONAL8_9_0_, this_.VALID_FLAG as VALID9_9_0_, this_.DISPLAY_FLAG as DISPLAY10_9_0_ from SYS_DICTIONARY this_ order by this_.SORTINDEX asc]; SQL state [null]; error code [-99999]; null; nested exception is com.ibm.db2.jcc.c.SqlException
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysDictionaryService' defined in URL [file:/E:/software/Tomcat5.5/webapps/cim/WEB-INF/classes/module/base/spring-service-info.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.ID as ID9_0_, this_.PARENTID as PARENTID9_0_, this_.CODE as CODE9_0_, this_.REMARK as REMARK9_0_, this_.CODE_DICT as CODE5_9_0_, this_.SORTINDEX as SORTINDEX9_0_, this_.NAME as NAME9_0_, this_.ADDITIONAL_CTRL as ADDITIONAL8_9_0_, this_.VALID_FLAG as VALID9_9_0_, this_.DISPLAY_FLAG as DISPLAY10_9_0_ from SYS_DICTIONARY this_ order by this_.SORTINDEX asc]; SQL state [null]; error code [-99999]; null; nested exception is com.ibm.db2.jcc.c.SqlException
Caused by:
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.ID as ID9_0_, this_.PARENTID as PARENTID9_0_, this_.CODE as CODE9_0_, this_.REMARK as REMARK9_0_, this_.CODE_DICT as CODE5_9_0_, this_.SORTINDEX as SORTINDEX9_0_, this_.NAME as NAME9_0_, this_.ADDITIONAL_CTRL as ADDITIONAL8_9_0_, this_.VALID_FLAG as VALID9_9_0_, this_.DISPLAY_FLAG as DISPLAY10_9_0_ from SYS_DICTIONARY this_ order by this_.SORTINDEX asc]; SQL state [null]; error code [-99999]; null; nested exception is com.ibm.db2.jcc.c.SqlException
Caused by:
com.ibm.db2.jcc.c.SqlException
at com.ibm.db2.jcc.c.s.a(s.java:1517)
at com.ibm.db2.jcc.c.s.m(s.java:465)
at com.ibm.db2.jcc.c.s.M(s.java:1102)
at com.ibm.db2.jcc.c.lf.getString(lf.java:959)
at com.ibm.db2.jcc.c.lf.getString(lf.java:1290)
at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:224)
at org.hibernate.type.StringType.get(StringType.java:18)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2031)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1371)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1299)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:568)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)

======================================================================

[color=red]【解决方法】:经过48小时的折腾结果发现,从服务器导出的文本数据是GBK编码,而DB2数据库在建数据库的时候选择的是UTF-8编码,所以导入本地数据库后中文是乱码和null,只要把服务器导出来的文本数据使用记事本或其它的编辑器(如:EditPlus,UltraEdit等)把文本文件保存为UTF-8格工,重新再导入数据库即可![/color]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值