当前位置:网站首页>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
边栏推荐
- 项目实战 五 拟合直线 获得中线
- ViewModelProvider.of 过时方法解决
- dolphinscheduler3.x本地启动
- Several key steps of software testing, you need to know
- ICML 2022 | explore the best architecture and training method of language model
- 安装VMmare时候提示hyper-v / device defender 侧通道安全性
- dolphinscheduler3. X local startup
- Stack and queue-p79-10 [2014 unified examination real question]
- 【从零开始】win10系统部署Yolov5详细过程(CPU,无GPU)
- Force deduction 62 different paths (the number of all paths from the upper left to the lower right of the matrix) (dynamic planning)
猜你喜欢

How to set up in touch designer 2022 to solve the problem that leap motion is not recognized?

Developers don't miss it! Oar hacker marathon phase III chain oar track registration opens

字符串常量与字符串对象分配内存时的区别

雷特智能家居龙海祁:从专业调光到全宅智能,20年专注成就专业

Pinduoduo lost the lawsuit: "bargain for free" infringed the right to know but did not constitute fraud, and was sentenced to pay 400 yuan

A program lets you understand what static inner classes, local inner classes, and anonymous inner classes are

Implementation of VGA protocol based on FPGA

MySQL卸载文档-Windows版

Leite smart home longhaiqi: from professional dimming to full house intelligence, 20 years of focus on professional achievements

哈趣投影黑馬之姿,僅用半年强勢突圍千元投影儀市場!
随机推荐
Abnova 体外转录 mRNA工作流程和加帽方法介绍
Three updates to build applications for different types of devices | 2022 i/o key review
Calculation model FPS
MySQL (x)
微信小程序隐藏video标签的进度条组件
拼多多败诉:“砍价免费拿”侵犯知情权但不构成欺诈,被判赔400元
安装VMmare时候提示hyper-v / device defender 侧通道安全性
JWT 认证
ip地址那点事
力扣62 不同路径(从矩阵左上到右下的所有路径数量) (动态规划)
How to install swoole under window
Open the blue screen after VMware installation
VIM mapping large K
Programmers' daily | daily anecdotes
Install mongodb database
Postgresql中procedure支持事务语法(实例&分析)
[SOC FPGA] peripheral PIO button lights up
Common problems of caching in high concurrency scenarios
Basic DOS commands
程序员的日常 | 每日趣闻