Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

any chance to know the charset of a remote database?

 
Max Durham
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What database? MySQL has SHOW CHARACTER SET since 4.1.

Cheers,
 
Max Durham
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic