[Opensource] utf-8 problem

ershad ershadr at yahoo.com
Mon Jan 12 07:09:19 PST 2004


Hello All
 
I have a curious problem when I try to work with utf-8 in my database.I have done the following:
1. setCharset("utf-8") is called in my DBObject.
2. content type is set in my JSPs with charset=utf-8
3. I am using mysql with utf8 support and com.mysql.jdbc.Driver JDBC (there is no problem with utf8 when I work directly with mysql command prompt). 

But both my own controllers and forms and DBMaint corrupt data during add and update.
I am suspicious with JDBC because as I tried to update a row directly via PreparedStatment it did not worked as well. There was no errors as before but it corrupted my data.The code  is shown below. 
Can anybody give me a hint for this problem.My project should be multilingual and this problem has made me really frustrated :(
 
 
 Class.forName("com.mysql.jdbc.Driver").newInstance();
 Connection connection = DriverManager.getConnection("jdbc:mysql://sprout:3306/sprout?user=ershad&password=123");
 
String UPDATE=new String("UPDATE DEPARTMENT SET name = 'ewqeq' , phone = '432423' , assistantManager = null , departmentManager = null , fax = '' , note = ? , refCompany = 1 , addedBy = 3 , updatedBy = 3 , AddedOn = '2003-11-11 17:47:26' , UpdatedOn = '2003-11-11 19:11:22'  WHERE departmentSeq = 2");

 PreparedStatement ps=connection.prepareStatement(UPDATE);
 String name="ÇÑÔÇÏ";
 byte[] name_b=name.getBytes("UTF8");
 ps.setString(1,new String(name_b,"UTF8"));
 ps.executeUpdate();




---------------------------------
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.jcorporate.com/pipermail/opensource/attachments/20040112/e0a0e091/attachment-0002.htm


More information about the Opensource mailing list