472,956 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,956 software developers and data experts.

JDBC DatabaseMetaData problem

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.j ava:270)
at org.postgresql.core.Encoding.decode(Encoding.java: 165)
at org.postgresql.core.Encoding.decode(Encoding.java: 181)
at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getStr ing(AbstractJdbc1ResultSet.java:97)
at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getStr ing(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.
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #1
1 4442
Wrong list. Please post this to the pg********@postgresql.org list.

I am sure there are people there that can help you with this.

Regards,
Fernando

Aleksey wrote:
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.j ava:270)
at org.postgresql.core.Encoding.decode(Encoding.java: 165)
at org.postgresql.core.Encoding.decode(Encoding.java: 181)
at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getStr ing(AbstractJdbc1ResultSet.java:97)

at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getStr ing(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.
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fn*****@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Swami | last post by:
Hi, I have installed MQ SQL Server 2000 on my laptop and trying to use SPRINTA 2000 JDBC Driver (inetmssql.jar) to connect to the local db. I wrote a sample Java app to test the connection and I...
3
by: aj | last post by:
Red Hat AS 2.1 DB2 WSE v8.1 FP5 Type 4 DB2 JDBC driver Using java.sql.DatabaseMetaData and ResultSetMetaData, I've written a JDBC/Java utility that shows, table by table, columns & their...
2
by: Maroon | last post by:
import java.sql.*; public class TESTA{ TESTA(){} public static int product() { try { Class.forName("com.ibm.db2.jcc.DB2Driver");
4
by: Ying Lu | last post by:
Hello, Under mysql, we have "desc tablename" to get the detail information about a table. My question is about to get column name, and column type for a specific table under PostgreSQL through...
15
by: Joe Weinstein | last post by:
Hi. Below is a simple JDBC program to insert and extract a numerical value. When ResultSet.getDouble() is called, the same program produces different output on solaris than it does on Linux. I...
3
by: drudini | last post by:
We have installed DB2UDB 8.2 on a windows 2003 server. How can I confirm the version of the JDBC driver that would have been installed with this? I wasn;t sure if the JBDC driver would have a...
1
by: Pete Geraghty | last post by:
I want to use DatabaseMetadata to retrieve details of those stored procedures which belong to the current schema. How can I find out what is the current schema for an existing Connection? Or...
2
by: dvawdrey | last post by:
Can someone help me please with the following code: try { DatabaseMetaData metadata=con.getMetaData(); System.out.println(metadata.getDriverName()); System.out.println("Driver version:...
9
bergy
by: bergy | last post by:
I am writing on an embedded device (J9 framework from IBM) that has a partial version of the java.sql package. It does not include Driver or DriverManager. I have downloaded the mysql Connector/J...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.