#1061 DB2:CharConversionException during retrieving table metadata

Core (462)

While connecting to a DB2 DB with db2jcc JDBC driver, CharConversionException is thrown during retrieving the metadata of a table:
com.ibm.db2.jcc.b.SqlException: [jcc][t4][1065][12306][3.53.95] Caught java.io.CharConversionException. See attached Throwable for details. ERRORCODE=-4220, SQLSTATE=null
at com.ibm.db2.jcc.b.bd.a(bd.java:660)
at com.ibm.db2.jcc.b.bd.a(bd.java:60)
at com.ibm.db2.jcc.b.bd.a(bd.java:112)
at com.ibm.db2.jcc.b.gc.a(gc.java:1807)
at com.ibm.db2.jcc.b.gc.n(gc.java:503)
at com.ibm.db2.jcc.b.gc.F(gc.java:1285)
at com.ibm.db2.jcc.b.vl.d(vl.java:1040)
at com.ibm.db2.jcc.b.vl.getString(vl.java:1018)
at net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData.getTables(SQLDatabaseMetaData.java:986)
at net.sourceforge.squirrel_sql.client.session.schemainfo.SchemaInfo.privateLoadTables(SchemaInfo.java:1211)
at net.sourceforge.squirrel_sql.client.session.schemainfo.SchemaInfo.loadTables(SchemaInfo.java:446)
at net.sourceforge.squirrel_sql.client.session.schemainfo.SchemaInfo.privateLoadAll(SchemaInfo.java:347)
at net.sourceforge.squirrel_sql.client.session.schemainfo.SchemaInfo.initialLoad(SchemaInfo.java:187)
at net.sourceforge.squirrel_sql.client.session.Session$1.run(Session.java:240)
at net.sourceforge.squirrel_sql.fw.util.TaskExecuter.run(TaskExecuter.java:82)
at java.lang.Thread.run(Unknown Source)
Caused by: java.nio.charset.MalformedInputException: Input length = 6963
at com.ibm.db2.jcc.b.v.a(v.java:19)
at com.ibm.db2.jcc.b.gc.a(gc.java:1803)
... 12 more
Caused by: sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(Unknown Source)
at com.ibm.db2.jcc.b.v.a(v.java:16)
... 13 more

This renders unusable that session as the DB structure is incomplete or even missing.
The exception is caused by characters with invalid encoding in the REMARKS field of a table's metadata.

For users who can't fix the table's remarks for some reason, a patch is attached to make SQuirrel SQL a little bit more fail safe (indeed the exception is written to the table's info object).


Bugs: #1076


  • Gabor Keresztfalvi

    patch for workaround

  • Rob Manning

    Rob Manning - 2012-11-14

    That's very curious. It makes one wonder why on earth would the driver allow you to write characters with invalid encodings in the REMARKS field, when they cannot be read. In any case, I would say that your DB2 session is pretty useless if SQuirreL cannot get a list of tables (e.g. No table nodes in the object tree, no code completion based on table names, etc.). So supposing the session degraded gracefully (rather than fail and become utterly useless), what value would that provide to you? In other words, it seems like all you want is to execute SQL at that point, correct?


  • Gabor Keresztfalvi

    Probably the codepage was wrong during execution of the create scripts... By the way the DB2 CLI can read the metadata without any error (of course the output is garbled), only the JDBC driver dies.

    With the attached patch the Exception thrown by the driver during the conversion of the REMARKS column is handled gracefully, so the object tree is propagated correctly. From that point the session is fully functional (also code completion works).

    I agree that this is a nasty workaround of a crappy driver/codepage combo, so I should have created a patch request instead of this bug. :)

  • Gerd Wagner

    Gerd Wagner - 2013-04-22

    The patch from bug #1076 has been applied.
    A snapshot younger than that of 2013-03-25 should show up soon at:

    Since I cannot reproduce the problem please let me know if the fix works. This should be the last change that goes into 3.5. We are willing to release 3.5 as soon as possible.



  • Gerd Wagner

    Gerd Wagner - 2013-04-22
    • status: open --> closed-fixed
  • Gabor Keresztfalvi

    I can confirm that Snapshot-20130422_2000 fixes my problem without any additional hacks.
    Thanks for merging the patch.

  • Gerd Wagner

    Gerd Wagner - 2013-04-23

    Thanks for your quick response.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks