[Opensource] utf-8 problem
Mike Traum
mtraum at jgroup.net
Mon Jan 12 10:58:52 PST 2004
I think it depends on your jdbc driver version, but adding:
useUnicode=true&characterEncoding=UTF-8
(jdbc:mysql://sprout:3306/sprout?user=ershad&password=123&useUnicode=true&characterEncoding=UTF-8)
to the jdbc connection string should take care of it.
There are several possibilities for failure here, so let us know if that
wasn't a cure-all...
hth,
mike
On Mon, 2004-01-12 at 09:09, ershad wrote:
> 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
--
Mike Traum
--
JGroup Expert
Expresso Core Developer
Providing support and development services - Available Now!
More information about the Opensource
mailing list