当前位置:网站首页>DB2获取表信息异常:Caused by: com.ibm.db2.jcc.am.SqlException: [jcc][t4][1065][12306][4.25.13]
DB2获取表信息异常:Caused by: com.ibm.db2.jcc.am.SqlException: [jcc][t4][1065][12306][4.25.13]
2022-07-07 02:19:00 【学无耻境】
问题描述:
DB2版本:DB2 v10.5.0.11
当JDBC通过JCC驱动(db2驱动)的DatabaseMetaData中的getTables获取数据库表信息抛出异常:
Caused by: com.ibm.db2.jcc.am.SqlException: [jcc][t4][1065][12306][4.25.13] 捕获到 java.io.CharConversionException。有关详细信息,请参阅相连接的 Throwable。 ERRORCODE=-4220, SQLSTATE=null
at com.ibm.db2.jcc.am.b6.a(b6.java:794)
at com.ibm.db2.jcc.am.b6.a(b6.java:66)
at com.ibm.db2.jcc.am.b6.a(b6.java:125)
at com.ibm.db2.jcc.am.bh.a(bh.java:2963)
at com.ibm.db2.jcc.am.bh.p(bh.java:575)
at com.ibm.db2.jcc.am.bh.P(bh.java:1656)
at com.ibm.db2.jcc.am.ResultSet.getStringX(ResultSet.java:1225)
at com.ibm.db2.jcc.am.ResultSet.getString(ResultSet.java:1194)
at com.ibm.db2.jcc.am.ResultSet.getString(ResultSet.java:1787)
at com.geominfo.bi.meta.crawler.AbstractMetaCrawler.getTableAndRemarks(AbstractMetaCrawler.java:539)
... 80 common frames omitted
Caused by: java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
at com.ibm.db2.jcc.am.x.a(x.java:52)
at com.ibm.db2.jcc.am.bh.a(bh.java:2952)
... 86 common frames omitted
原因
当 JCC 驱动程序查询的字符列中的数据不是数据库代码页中的有效字符串时,JCC 驱动程序将引发异常。
无效数据可能已通过以下方式输入到数据库:
通过运行将字节值写入数据库的 SQL 语句。例如:INSERT INTO tab1 VALUES (X’C3’)
通过对包含不在客户端计算机代码页中的字符数据的文件运行 IMPORT 或 LOAD 命令,因此未执行相应的代码页转换。若要确保在运行 IMPORT 或 LOAD 时完成相应的代码页转换,请通过包含文件类型修饰符(指定代码页代替 x)来指定输入文件的代码页。“codepage=x”
诊断问题
您可以使用十六进制函数找出字符列中的字节值。
例如,要找出表 TAB1 中 COL1 列中的字节值,请运行:
SELECT HEX(col1) FROM tab1
解决问题
使用有效的 UTF-8 字符串更新无效数据。
或者,对于支持它的 JCC 驱动程序版本,您可以设置 JCC 配置属性 db2.jcc.charsetDecoderEncoder=3,以便 JCC 驱动程序不引发异常,而是返回 Unicode 替换字符 (U+FFFD) 代替不是有效 UTF-8 字符串的字节序列。
JCC 配置属性 db2.jcc.charsetDecoderEncoder 在 DB2 LUW 9.5 FP8 及更高版本 (APAR IC74896)、DB2 LUW 9.7 FP 5 及更高版本 (APAR IC74895) 以及从 DB2 10.1 开始的所有 DB2 LUW 发行版中受支持。
例如,假设您有一个 Java 程序 MyApp.java它执行对数据库列的 SQL 查询,该数据库列包含一个不是有效字符串的字节序列。
运行时:
它会引发异常。但是当你运行时:
它返回的字符串包含任何无效的字节序列,这些字节序列被Unicode替换字符替换。
Unicode 替换字符通常如下所示
java -Dfile.encoding=gb18030 -Ddb2.jcc.charsetDecoderEncoder=3 -jar MyApp.jar
参考资料:
https://www.itdaan.com/blog/2015/05/09/3f8fc9857f8b3de1669d63b3abaad6f1.html
https://www.ibm.com/support/pages/sqlexception-message-caught-javaiocharconversionexception-and-errorcode-4220
https://www.it1352.com/2818869.html
https://www.cnblogs.com/lpzpp/p/13986533.html
边栏推荐
- Wechat applet hides the progress bar component of the video tag
- Several key steps of software testing, you need to know
- 「运维有小邓」符合GDPR的合规要求
- C面试24. (指针)定义一个含有20个元素的double型数组a
- Redhat5 installing vmware tools under virtual machine
- 怎样查找某个外文期刊的文献?
- Overview of FlexRay communication protocol
- Tkinter window selects PCD file and displays point cloud (open3d)
- c面试 加密程序:由键盘输入明文,通过加密程序转换成密文并输出到屏幕上。
- Test the foundation of development, and teach you to prepare for a fully functional web platform environment
猜你喜欢

Cloudcompare point pair selection

Abnova循环肿瘤DNA丨全血分离,基因组DNA萃取分析

uniapp开发小程序如何使用微信云托管或云函数进行云开发

FlexRay通信协议概述

How to keep accounts of expenses in life

Redhat5 installing vmware tools under virtual machine

【OpenCV】形态学滤波(2):开运算、形态学梯度、顶帽、黑帽

How can I check the DOI number of a foreign document?

MySQL卸载文档-Windows版
SVN version management in use replacement release and connection reset
随机推荐
雷特智能家居龙海祁:从专业调光到全宅智能,20年专注成就专业
Abnova 膜蛋白脂蛋白体技术及类别展示
A program lets you understand what static inner classes, local inner classes, and anonymous inner classes are
Apache ab 压力测试
mobx 知识点集合案例(快速入门)
JESD204B时钟网络
How to install swoole under window
Go straight to the 2022ecdc fluorite cloud Developer Conference: work with thousands of industries to accelerate intelligent upgrading
Which foreign language periodicals are famous in geology?
BindingException 异常(报错)处理
地质学类比较有名的外文期刊有哪些?
dolphinscheduler3. X local startup
Markdown displays pictures side by side
[FPGA] EEPROM based on I2C
Jmeter 5.5版本发布说明
Unity C# 函数笔记
Ha Qu projection dark horse posture, only half a year to break through the 1000 yuan projector market!
Matlab / envi principal component analysis implementation and result analysis
Redis(一)——初识Redis
What books can greatly improve programming ideas and abilities?