Dyapa Srikanth
Dyapa Srikanth

Reputation: 1241

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.

Upvotes: 3

Views: 2776

Answers (1)

duffymo
duffymo

Reputation: 308763

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.

Upvotes: 3

Related Questions