Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2007

Tip: Looking for answers? Try searching our database.

JTextField  Unicode  Mysql

Thread view: 
Badshah - 26 Jan 2007 12:31 GMT
Hello Friends, How are you ? I am Sohil. I am here with a problem

I am creating a text editor that will store data in mySql database. I
want to get the data in text field. I am having "♥" character in
database.

Select * from bank_master;
+---------+-----------+
| Bank_Id | Bank_Name |
+---------+-----------+
|       3 | ♥         |
+---------+-----------+

I am not able to display this character in textbox. The text box is
showing a rectangle  instead of that character.

    textfield.setText(rs.getString("Bank_Name"));

But, when I am retriving the character from text box and display it on
the command prompt console it shows right character ie. "♥"

    System.out.println(textfield.getText());

I am not able to get the problem here.

Sohil Surti
mikey - 28 Jan 2007 06:32 GMT
Hi Sohil,

your problem is that what you have in the database is a bitpattern that
can be interpreted differently. The interpretation of a bitpattern as a
string of characters is called 'encoding'. What you are seeing here is
that the DOS box uses an encoding with a name/number I can't remember
right now while the textfield probably uses an encoding named 'UTF8'.

'UTF8' is far superior to the encoding used by DOS if you plan on any
internationalization (google for UNICODE). So you should stick with that
 and think about where the data in the DB came from. You'll probably
have to do some conversion.

Cheers

> Hello Friends, How are you ? I am Sohil. I am here with a problem
>
[quoted text clipped - 22 lines]
>
> Sohil Surti


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.