Hello all,

I have a J2EE application that displays a dropdown of items, in Arabic text.
This data is stored in a table in underlying MySQL server.

The DB character set is set to utf8 and I have in my JSP the carset encoding as utf8 as well.

This works correctly on my workstation that runs windows 10, with my local MySQL db and other components [tomcat7 and httpd].
When I deploy my webapp WAR on the server [Centos7, linux], that has its own MySQL/tomcat7/httpd [all same versions and setups], then the content of my drop-down that's coming from MySQL table, displays as ????

Can someone please advise, where to look for resolution or at least point me to the right direction?

Thanks in advance.

I think I know where the problem is.

I have written a java program to load my CSV into my mysql database.
When I do a select from underlying DB, using mysql command utility, even the data in my table is stored as ????

I entered manually an arabic text into my table, and it displays it correctly.
So, I believe something is not correct with my JAva program that loads data. Here's the program, and not sure what's wrong iwth it. In windows it works just fine.

public class LoadCSV {
    public static void main(String [] agrs) {
        LoadCSV bi = new LoadCSV();

        bi.execute(bi.loadProp());
    }

    private Properties loadProp() {
        Properties prop = new Properties();
        InputStream input = null;
        try {
            input = new FileInputStream("/home/miacnt/item.properties");
            prop.load(input);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return prop;
    }

  public void execute(Properties prop) {

    SimpleDateFormat sdf =new SimpleDateFormat("dd-MM-yyyy hh:mm:ss",Locale.CANADA);
    System.out.println("Started: " + sdf.format(new Date()));
    String csvFile = prop.getProperty("csv_file");
    BufferedReader br = null;
    String line = "";

    Connection connection = SqlUtil.getMySQLConnection(prop);
    String selectSQL="";

    try {
        InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(csvFile), "UTF-8");
        br = new BufferedReader(inputStreamReader);
        while ((line = br.readLine()) != null) {
            String[] itemInfo = line.split(prop.getProperty("csv_separator"), 16);

            String e_code = itemInfo[0];
            String e_val = itemInfo[1];
            String i_code = itemInfo[2];
            String i_val = itemInfo[3];


            String sqlInsert = "INSERT INTO item_table (e_code, e_val, i_code, i_val) VALUES(?,?,?,?)";
            PreparedStatement statement = connection.prepareStatement(sqlInsert);

            statement.setString(1, e_code

    );
                statement.setString(2, e_val);
                statement.setString(3, i_code);
                statement.setString(4, i_val);


                statement.executeUpdate();
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            System.out.println("Exception in SELECT SQL: " + selectSQL);
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                    connection.close();
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }

        System.out.println("Completed: " + sdf.format(new Date()));
        System.out.println("Done loading CSV");
      }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.