当前位置:网站首页>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
边栏推荐
- Experience sharing of contribution of "management world"
- SVN version management in use replacement release and connection reset
- uniapp开发小程序如何使用微信云托管或云函数进行云开发
- How to install swoole under window
- Redis (I) -- getting to know redis for the first time
- Matlab / envi principal component analysis implementation and result analysis
- What are the classic database questions in the interview?
- Learning notes | data Xiaobai uses dataease to make a large data screen
- How to solve sqlstate[hy000]: General error: 1364 field 'xxxxx' doesn't have a default value error
- Niuke Xiaobai monthly race 52 E. sum logarithms in groups (two points & inclusion and exclusion)
猜你喜欢
Several key steps of software testing, you need to know
软件测试到了35岁,真的就干不动了吗?
Programmers' daily | daily anecdotes
Which foreign language periodicals are famous in geology?
哈趣投影黑马之姿,仅用半年强势突围千元投影仪市场!
[SOC FPGA] custom IP PWM breathing lamp
屏幕程序用串口无法调试情况
Doctoral application | Professor Hong Liang, Academy of natural sciences, Shanghai Jiaotong University, enrolls doctoral students in deep learning
Redhat5 installing vmware tools under virtual machine
面试中有哪些经典的数据库问题?
随机推荐
【OpenCV】形态学滤波(2):开运算、形态学梯度、顶帽、黑帽
LM11丨重构K线构建择时交易策略
js装饰器@decorator学习笔记
MySQL(十)
ip地址那点事
常用函数detect_image/predict
POI export to excel: set font, color, row height adaptation, column width adaptation, lock cells, merge cells
Stack and queue-p78-8 [2011 unified examination true question]
项目实战 五 拟合直线 获得中线
偏执的非合格公司
What books can greatly improve programming ideas and abilities?
A program lets you understand what static inner classes, local inner classes, and anonymous inner classes are
Unable to debug screen program with serial port
Abnova循环肿瘤DNA丨全血分离,基因组DNA萃取分析
How to use wechat cloud hosting or cloud functions for cloud development of unapp development applet
C面试24. (指针)定义一个含有20个元素的double型数组a
[SOC FPGA] peripheral PIO button lights up
Party A's requirements for those who have lost 800 yuan
Three updates to build applications for different types of devices | 2022 i/o key review
Audio distortion analysis of DSP and DAC based on adau1452