X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B0E9AD1B503 for ; Wed, 29 Oct 2003 19:38:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 88740-02 for ; Wed, 29 Oct 2003 15:37:32 -0400 (AST) Received: from Tor.farlep.net (tor.farlep.net [213.130.1.225]) by svr1.postgresql.org (Postfix) with ESMTP id 5BE92D1B4E9 for ; Wed, 29 Oct 2003 15:37:28 -0400 (AST) Received: from ukr.net (nas-6-108.dialup.farlep.net [213.130.4.237]) by Tor.farlep.net with ESMTP id h9TJb2VJ021703 for ; Wed, 29 Oct 2003 21:37:08 +0200 Message-ID: <3FA016F4.5070904@ukr.net> Date: Wed, 29 Oct 2003 21:37:24 +0200 From: Aleksey Organization: Local User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: ru, en, en-us MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: JDBC DatabaseMetaData problem Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/114 X-Sequence-Number: 8544 Hello, 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(rs.next()) { 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(Encoding.java:270) at org.postgresql.core.Encoding.decode(Encoding.java:165) at org.postgresql.core.Encoding.decode(Encoding.java:181) at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getString(AbstractJdbc1ResultSet.java:97) at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getString(AbstractJdbc1ResultSet.java:337) 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 http://jdbc.postgresql.org/download/pg73jdbc3.jar on Linux, J2SDK 1.4.1_02. I will appreciate any help with this. Thank you. Sincerely yours, Aleksey.