当前位置:网站首页>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
边栏推荐
- 【OpenCV】形态学滤波(2):开运算、形态学梯度、顶帽、黑帽
- 如何解决数据库插入数据显示SQLSTATE[HY000]: General error: 1364 Field ‘xxxxx‘ doesn‘t have a default value错误
- Knight defeats demon king (Backpack & DP)
- 当前发布的SKU(销售规格)信息中包含疑似与宝贝无关的字
- Navicat importing 15g data reports an error [2013 - lost connection to MySQL server during query] [1153: got a packet bigger]
- UIC(组态UI工程)公版文件库新增7款行业素材
- Shared memory for interprocess communication
- 哈趣投影黑馬之姿,僅用半年强勢突圍千元投影儀市場!
- 线性代数(一)
- Array proof during st table preprocessing
猜你喜欢

JWT certification

String (explanation)

How to install swoole under window

Tkinter window selects PCD file and displays point cloud (open3d)

Go straight to the 2022ecdc fluorite cloud Developer Conference: work with thousands of industries to accelerate intelligent upgrading

Prompt for channel security on the super-v / device defender side when installing vmmare

线性代数(一)

BindingException 异常(报错)处理

Etcd database source code analysis -- starting from the start function of raftnode

哈趣投影黑马之姿,仅用半年强势突围千元投影仪市场!
随机推荐
基本Dos命令
Array proof during st table preprocessing
C language (structure) defines a user structure with the following fields:
软件测试到了35岁,真的就干不动了吗?
Ha Qu projection dark horse posture, only half a year to break through the 1000 yuan projector market!
学习笔记|数据小白使用DataEase制作数据大屏
CloudCompare-点对选取
Abnova 膜蛋白脂蛋白体技术及类别展示
循环肿瘤细胞——Abnova 解决方案来啦
How can I check the DOI number of a foreign document?
Can't you really do it when you are 35 years old?
ICML 2022 | 探索语言模型的最佳架构和训练方法
HKUST & MsrA new research: on image to image conversion, fine tuning is all you need
ViewModelProvider.of 过时方法解决
LM small programmable controller software (based on CoDeSys) Note 23: conversion of relative coordinates of servo motor operation (stepping motor) to absolute coordinates
How to solve sqlstate[hy000]: General error: 1364 field 'xxxxx' doesn't have a default value error
c语言(结构体)定义一个User结构体,含以下字段:
Test the foundation of development, and teach you to prepare for a fully functional web platform environment
哈趣投影黑馬之姿,僅用半年强勢突圍千元投影儀市場!
String (explanation)