I have a Java application, you want to insert arabic words into mysql database, my code looks like
Connection con = null;
String url = "jdbc:mysql://localhost/";
String db = "students";
String driver = "com.mysql.jdbc.Driver";
try {
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","");
Statement st = con.createStatement();
String name = new String(txtName.getText().getBytes(), "UTF-8");
int val = st.executeUpdate("insert into student(name, roll) VALUES('"+name+"','"+txtRoll.getText()+"')");
} catch (Exception ex) {
ex.printStackTrace();
}
But he only inserts '??????'. what can i do now
source
share