Skip site navigation (1) Skip section navigation (2)

DatabaseMetaData - getImportedKeys

From: Aleksey <phone(at)ukr(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: DatabaseMetaData - getImportedKeys
Date: 2003-11-03 02:52:25
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

I have the following problem working with DatabaseMetaData. There is a
database with table and attribute names in Russian. Database cluster was
initialized with appropriate ru_RU.KOI8-R locale. All the databases were
created with KOI8-R encoding. No problems were encountered in accessing
database table data with JDBC.

Database has foreign key constraints that I try to get with
DatabaseMetaData methods. Both getTables and getPrimaryKeys work fine,
all the results have correct encoding and values.

The following fragment of code causes exception:

rs = meta.getImportedKeys(null,null,tableName);
while( {

    String pkTable = rs1.getString("PKTABLE_NAME");
    String pkColumn = rs1.getString("PKCOLUMN_NAME");  /* here */

    String fkTable = rs1.getString("FKTABLE_NAME");
    String fkColumn = rs1.getString("FKCOLUMN_NAME"); /* and here */


PKTABLE_NAME and FKTABLE_NAME fields are fetched correctly. Both the
marked lines produce exception with this stack trace:

at org.postgresql.core.Encoding.decodeUTF8(
at org.postgresql.core.Encoding.decode(
at org.postgresql.core.Encoding.decode(

Error message is: "Invalid character data was found.  This is most
likely caused by stored data containing characters that are invalid for
the character set the database was created in.  The most common example
of this is storing 8bit data in a SQL_ASCII database.",

but database is not SQL_ASCII (actually KOI8-R) and all the characters
in column names are taken from this codepage. Other DatabaseMetaData
methods work with these characters fine.

I tested the same methods with the same database but with tables with
latin names - everything worked fine, but renaming all the columns will
cause a huge amount of extra work with database and applications.

I use PostgreSQL-7.3.4 compiled from source, JDBC driver from on Linux, J2SDK 1.4.1_02.

I will appreciate any help with this.

Thank you.

Sincerely yours,


pgsql-jdbc by date

Next:From: Kris JurkaDate: 2003-11-03 03:40:59
Subject: Re: DatabaseMetaData - getImportedKeys
Previous:From: Dave CramerDate: 2003-11-03 00:24:11
Subject: Re: automatic sequence number?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group