1

I'm using this code

try {
            String connectionURL = "jdbc:mysql://localhost:3306/mydb"; 

            Connection connection = null; 
            Class.forName("com.mysql.jdbc.Driver").newInstance(); 

            connection = DriverManager.getConnection(connectionURL, "root", "");

            if(!connection.isClosed())
                System.out.println("Successfully connected to " + "MySQL server using TCP/IP...");
            ResultSet rs = null;


            Statement statement = null;
            statement = connection.createStatement();
            // sql query to retrieve values from the secified table.
            String QueryString = "SELECT `Text` FROM `card` WHERE `CardID`=1";
            rs = statement.executeQuery(QueryString);
            String arabictext ="";
            while (rs.next()) {
                System.out.println(rs.getString(1));
                arabictext += rs.getString(1);

            }
            rs.close();
            statement.close();
        }
        catch(Exception ex){
            System.out.println("Unable to connect to database.");
        }

Text column in card table is text type and utf8_unicode_ci Collation. When I execute above query which fetch Arabic text then it didn't show in right format instead it show question marks like ?????. I print this on console and on jsp page, but it is showing ??? on both.

Bills
  • 768
  • 7
  • 19

1 Answers1

0

You might looking for Character Encoding

If you don't even know where to get Arabic characters, but you want to display them, then you're doing something wrong.

Save files containing Arabic characters with encoding UTF-8. A good editor allows you to set the character encoding. In the HTML page, place the following after :

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

If you're using XHTML:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

Refrence https://stackoverflow.com/a/3601802/2236219

Community
  • 1
  • 1
Manwal
  • 23,450
  • 12
  • 63
  • 93