File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes any chance to know the charset of a remote database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "any chance to know the charset of a remote database?" Watch "any chance to know the charset of a remote database?" New topic
Author

any chance to know the charset of a remote database?

Max Durham
Greenhorn

Joined: Jul 14, 2004
Posts: 7
i need to retrieve some chinese characters from db, well, seems that's sth i cant do properly without knowing its charset first

anyone thoughts?
Regards
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
What database? MySQL has SHOW CHARACTER SET since 4.1.

Cheers,


Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
Max Durham
Greenhorn

Joined: Jul 14, 2004
Posts: 7
i meant via jdbc, i gotta write a snippet to tell what the charset is in the server side and then retrieve the character with corresponding charset in the client side
eg.
server client
utf8 iso-8859-1
gbk gbk

any thoughts?
Cheers
Charu Singh
Greenhorn

Joined: Jun 10, 2005
Posts: 20
I'm facing exactly same problem, I have to dislay some Danish characters.
When I try to do so I get a '?' in place of the character.

Tried converting the String returned from <resultset>.getString("TITLE"); method in to Byte array and passing it to String constructor, that is :-> String(byte[],"UTF-16") that creates String out of the byte array using the Encoding passed as second parameter.
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
Again, what database? Using JDBC with MySQL you execute "SHOW CHARACTER SET;". The single row result set then contains the character set name the database uses.

Refer to Chapter 10 in MySQL documentation for more info on character set support in MySql.
Pawan M Singh
Greenhorn

Joined: Sep 14, 2005
Posts: 2
You can use "utl_i18n.get_default_charset" function in Oracle to get the CharacterSet.
Syntax :
utl_i18n.get_default_charset(language IN VARCHAR2,
context IN PLS_INTEGER DEFAULT GENERIC_CONTEXT,
iswindows IN BOOLEAN DEFAULT FALSE) RETURN VARCHAR2;

Like :
SELECT utl_i18n.get_default_charset(<Your_language_name>,0) FROM dual;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: any chance to know the charset of a remote database?