Wednesday, June 30, 2010

Successful arabic from GWT client form into MySQL

I could not find a good recipe for inserting Arabic entered on a GWT
page into a text field to be inserted into MySQL as anything other
than "?????????". Here is a simplified example


private RichTextArea arabicNameField = new RichTextArea();
//First thing we discovered is this only reliably works in a
RichTextArea, a TextBox does not seem to work for arabic

myService.insertText(arabicName, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {

// we don't do anything here for saving
public void onSuccess(Void result) {

//The Key is in the UTF encoding and getting the bytes rather than
the text
String queryString = "insert into names (arabicname) values (?)";

mySqlStatement = con.prepareStatement(queryString);

try {
mySqlStatement.setBytes(1, arabicName.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
mySqlStatement.setString(1, "Unable to Encode Name");


You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment