473,698 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JDBC DatabaseMetaDat a problem

Hello,

I have the following problem working with DatabaseMetaDat a. 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
DatabaseMetaDat a methods. Both getTables and getPrimaryKeys work fine,
all the results have correct encoding and values.

The following fragment of code causes exception:

rs = meta.getImporte dKeys(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.d ecodeUTF8(Encod ing.java:270)
at org.postgresql. core.Encoding.d ecode(Encoding. java:165)
at org.postgresql. core.Encoding.d ecode(Encoding. java:181)
at
org.postgresql. jdbc1.AbstractJ dbc1ResultSet.g etString(Abstra ctJdbc1ResultSe t.java:97)
at
org.postgresql. jdbc1.AbstractJ dbc1ResultSet.g etString(Abstra ctJdbc1ResultSe t.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 DatabaseMetaDat a
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 4490
Wrong list. Please post this to the pg********@post gresql.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 DatabaseMetaDat a. 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
DatabaseMetaDat a methods. Both getTables and getPrimaryKeys work fine,
all the results have correct encoding and values.

The following fragment of code causes exception:

rs = meta.getImporte dKeys(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.d ecodeUTF8(Encod ing.java:270)
at org.postgresql. core.Encoding.d ecode(Encoding. java:165)
at org.postgresql. core.Encoding.d ecode(Encoding. java:181)
at
org.postgresql. jdbc1.AbstractJ dbc1ResultSet.g etString(Abstra ctJdbc1ResultSe t.java:97)

at
org.postgresql. jdbc1.AbstractJ dbc1ResultSet.g etString(Abstra ctJdbc1ResultSe t.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 DatabaseMetaDat a
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*******@postg resql.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
7253
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 get the following error trace, DriverManager.initialize: jdbc.drivers = null JDBC DriverManager initialized SQLException: SQLState(08S01) {sql7=true, port=1433, user=sa, url=jdbc:inetdae7:US0211737-WP01:1433,
3
3767
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 types, NOT NULLness, PK, FK, and unique indexes. But one thing that I can't seem to extract is info
2
3466
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
6453
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 JDBC. Assume we have a table named "test". Under PSQL, we can input "\d test" to see the details about table "test" successufully. However, my main purpose is trying to get column name, column name of a table through JDBC.
15
2458
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 would be grateful for any discussion of this! thanks, Joe Weinstein at BEA Systems Results on Linux Box -----------------------------------------------------------------------
3
1923
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 different version/build then the DB version itself. Thanks, Bob Cook
1
5069
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 alternatively is there any special syntax in the getProcedures method to limit the results to procedures belonging to the current schema? Is there any clear documentation about the interpretation to be given to catalog and schema in DB2's JDBC...
2
8623
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: " +metadata.getDriverVersion()); System.out.print("JDBC version: " + metadata.getJDBCMajorVersion()); System.out.println("." +metadata.getJDBCMinorVersion());
9
3248
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 but all of their examples use the DriverManager. Something like: conn = DriverManager.getConnection("jdbc:mysql://localhost/test?" + "user=monty&password=greatsqldb"); Does anyone know of any modules that...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.