IBM Support

ERRORCODE=-4221, InvalidKeyException when using AES encryption with DB2 JDBC Driver

Troubleshooting


Problem

May get error as "ERRORCODE=-4221, InvalidKeyException" from your Java application when using AES encryption with DB2 JDBC Driver

Symptom

The java application may return error message like below:

Exception: com.ibm.db2.jcc.am.SqlException: [jcc][1068][10625][4.15.82] Caught java.security.InvalidKeyException while encrypting data. See attached Throwable
for details. ERRORCODE=-4221, SQLSTATE=null
com.ibm.db2.jcc.am.SqlException: [jcc][1068][10625][4.15.82] Caught java.security.InvalidKeyException while encrypting data. See attached Throwable for details
. ERRORCODE=-4221, SQLSTATE=null
at com.ibm.db2.jcc.am.fd.a(fd.java:680)
at com.ibm.db2.jcc.am.fd.a(fd.java:60)
at com.ibm.db2.jcc.am.fd.a(fd.java:85)
at com.ibm.db2.jcc.am.rc.a(rc.java:557)
at com.ibm.db2.jcc.am.rc.a(rc.java:497)
at com.ibm.db2.jcc.t4.b.h(b.java:2837)
at com.ibm.db2.jcc.t4.b.a(b.java:6491)
at com.ibm.db2.jcc.t4.b.b(b.java:844)
at com.ibm.db2.jcc.t4.b.a(b.java:761)
at com.ibm.db2.jcc.t4.b.a(b.java:424)
at com.ibm.db2.jcc.t4.b.a(b.java:399)
at com.ibm.db2.jcc.t4.b.<init>(b.java:337)
at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource
.java:232)
at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource
.java:198)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:475)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:116)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at ConnectSample.main(ConnectSample.java:10)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1024)
at javax.crypto.Cipher.implInit(Cipher.java:790)
at javax.crypto.Cipher.chooseProvider(Cipher.java:849)
at javax.crypto.Cipher.init(Cipher.java:1348)
at javax.crypto.Cipher.init(Cipher.java:1282)
at com.ibm.db2.jcc.am.rc.a(rc.java:552)
... 15 more

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Programming Interface - JDBC","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;10.1;10.5","Edition":"Advanced Enterprise Server;Advanced Workgroup Server;Enterprise Server;Express;Personal;Workgroup Server","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

Modified date:
30 April 2025

UID

swg21668374