I want to read data from database. the data is in arabic language. the character set of my database is AL32UTF8.
when i try to retrive the data i get "????"
please do reply how to solve this problem
this is the code

public static void main(String[] args) {

        // TODO Auto-generated method stub

        String url = "jdbc:oracle:thin:@localhost:1521:xe";
        String username = "hr";
        String password = "hr";

        String sql = "SELECT WORDS_URDU FROM FINALLY WHERE DFFGG=430";
        Connection connection;
        try {
            connection = DriverManager.getConnection(url, username, password);
            Statement statement = connection.createStatement();
            ResultSet rs = statement.executeQuery(sql);
            while(rs.next())
            {


                System.out.println(rs.getString(1));
            }

            //System.out.println(statement.execute(sql));
            connection.close();
        } catch (SQLException e) {
            System.err.println(e);
        }

    }

Edited 2 Years Ago by khadija.cheeko

I'm no expert on this, but because nobody else seems to be around right now, I'll have a try...

It coulld be that
a) the 8 bit AL32UTF8 data isn't being converted to Unicode properly
or
b) the internal representation of the data is OK, but the character set you are using to display it doesn't have the right Unicode characters
or
c) something else...

For a) you could try forcing an explicit conversion by replacing your rs.getString(1) with
new String(read_rs.getBytes(1),"AL32UTF8")
For b) maybe try other fonts, especially Arabixc system fonts?
For c) maybe someone else can help

yeah i tried

new String(read_rs.getBytes(1),"AL32UTF8")

but it still gives "????" in result

So, maybe move on to b)?
You could look at the UniCode values of your Strings to see if those are the correct UniCode that you expect (get the first few chars and print them as numeric values)

System.out.println(Character.getNumericValue(s.charAt(0))); // etc

Edited 2 Years Ago by JamesCherrill

This article has been dead for over six months. Start a new discussion instead.