Getting error code 4220 with null SQL State

匿名 (未验证) 提交于 2019-12-03 00:57:01

问题:

I'm getting error code -4220 with null SQL State .the SP "XXXXX" contain VARGRAPHICS data type. Below is complete exception stack trace. SP is executing properly, the error is coming while reading output parameter i.e. execute method called successfully but getString method is giving error.

Even if I'm trying to access any method to get output parameter value, error is coming. Just FYI, I tried with latest version of db2 driver but still error persist.

    com.ibm.db2.jcc.am.SqlException: [jcc][t4][1065][12306][3.65.77] Caught java.io.CharConversionException.  See attached Throwable for details. ERRORCODE=-4220, SQLSTATE=null     at com.ibm.db2.jcc.am.cd.a(cd.java:682)     at com.ibm.db2.jcc.am.cd.a(cd.java:60)     at com.ibm.db2.jcc.am.cd.a(cd.java:112)     at com.ibm.db2.jcc.am.gc.a(gc.java:2825)     at com.ibm.db2.jcc.am.gc.a(gc.java:582)     at com.ibm.db2.jcc.am.gc.q(gc.java:560)     at com.ibm.db2.jcc.am.gc.N(gc.java:1557)     at com.ibm.db2.jcc.am.gc.a(gc.java:1541)     at com.ibm.db2.jcc.am.CallableStatement.D(CallableStatement.java:941)     at com.ibm.db2.jcc.am.CallableStatement.getString(CallableStatement.java:920)     at com.cst.test.daoLayer.SPTest.callDB2ProcOUTParameter(SPTest.java:118)     at com.cst.test.daoLayer.SPTest.testLogic(SPTest.java:235)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:618)     at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)     at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)     at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)     at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)     at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)     at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)     at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)     at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)     at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)     at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.nio.charset.MalformedInputException: Input length = 5     at com.ibm.db2.jcc.am.r.a(r.java:19)     at com.ibm.db2.jcc.am.gc.a(gc.java:2821)     ... 28 more Caused by: sun.io.MalformedInputException     at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java:278)     at com.ibm.db2.jcc.am.r.a(r.java:16)     ... 29 more 

回答1:

I fixed the issue by using latest version of jar and by setting below system property .

System.setProperty("db2.jcc.charsetDecoderEncoder", "3"); 

Also another way is disable unicode encoding for char and varchar type in DB2 SP which also worked for me ..



回答2:

After experiencing this same error, it turned out that older versions of the db2jcc jar do not support Java 8. After reverting to Java 7, the error goes away. This can also be resolved by downloading the newer/supported version of the jar from IBM.



回答3:

After a lot of research I found the exact jars to be downloaded to solve the CharConversionException. To be specific. This issue is resolved in the JDBC v9.7 Fix pack 5. This release addresses APAC74895 (which solves the CharConversionException) so that special characters in the db are skipped rather than an exception being thrown.

You need to download the appropriate jar from the IBM site

Then add the following environment variable(Java VM arguments) in ur tomcat settings -Ddb2.jcc.charsetDecoderEncoder=3

Thats it problem solved :)



回答4:

We encountered this problem after changing DB columns from CHAR to VARCHAR. The problem was resolved after restarting our Java WAS Server - apparently the DB2 driver needs a restart to cope with this.



回答5:

db2jcc.jar driver is now deprecated.

Identify your db2 version and include the latest db2jcc jar file to your build path.

In my case : Db2 version = 9.7.301.326 and i added

db2jcc-9.7.4.jar 

Refresh and rerun your application.It worked for me.

For more details : http://www-01.ibm.com/support/docview.wss?uid=swg21363866



回答6:

I was encountering the problem as my db2jcc jar was obsolete and my server was pointing to the obsolete jar for getting db2 connection.

Updating the db2jcc jar resolved my issue.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!