Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ResultSet getString character encoding for unicode characters

In my swing application I am going to display hindi unicode charecters from the database. When I am displaying name, it showing as it is, not as a hindi string.

But when I hardcoded it into the program it is showing correctly. What is the problem. Is there any charecter encoding option while getting the data from database. I am using oracle xe with Netbeans.

    String name = rs.getString("name");
    jLabel1.setText(name);

Here it displaying unicode charecters as it is. But here

    String name = "\u0938\u093e\u092e\u093e\u0928\u094d\u092f";
    jLabel1.setText(name);

It showing correctly. Where is the problem.

like image 312
Dyapa Srikanth Avatar asked Jun 23 '26 06:06

Dyapa Srikanth


1 Answers

The issue lies in the encoding that Oracle is using. You have to set it up to use UTF-8 in the database as well. Unfortunately, you can't fix this in the JDBC classes.

like image 181
duffymo Avatar answered Jun 24 '26 19:06

duffymo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!