lihanchuan125 发表于 2016-11-17 04:41:23

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

从DB2服务器导出文本数据导入本机,启动Tomcat5.5报错大概日志如下:org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL ; SQL state ; 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 : Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'noTranBatcher' defined in URL : Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysDictionaryService' defined in URL : Invocation of init method failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL ; SQL state ; 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 : Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysDictionaryService' defined in URL : Invocation of init method failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL ; SQL state ; 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 : Invocation of init method failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL ; SQL state ; 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 ; SQL state ; 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)

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

【解决方法】:经过48小时的折腾结果发现,从服务器导出的文本数据是GBK编码,而DB2数据库在建数据库的时候选择的是UTF-8编码,所以导入本地数据库后中文是乱码和null,只要把服务器导出来的文本数据使用记事本或其它的编辑器(如:EditPlus,UltraEdit等)把文本文件保存为UTF-8格工,重新再导入数据库即可!
页: [1]
查看完整版本: 【原创】DB2数据库乱码造成启动Tomcat5.5加载数据抛出异常!-已经解决