Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Roger Wilson
Upgrading to UTF-8
June 12, 2013 11:40 AM
Answer

Roger Wilson

Rank: Junior Member

Posts: 29

Join Date: February 20, 2013

Recent Posts

So there's been a request to use Chinese characters on our current liferay site. When attempting to save the translation, we started seeing errors like the following:

14:28:44,990 ERROR [org.hibernate.util.JDBCExceptionReporter] (http--0.0.0.0-8080-2) Incorrect string value: '\xE5\xA4\xA7\xE5\xA4\xA7...' for column 'content' at row 1

Going back and forth on this a while, I'm beginning to think that this database was not set up to use UTF-8 encoding. Which would lead me to 2 questions:

1. How can I confirm if the DB uses UTF-8 encoding?

and

2. Assuming it does not use UTF-8, how can I update/alter the existing tables so that UTF-8 is used?

I've seen a few mechanisms by how UTF-8 is set up, but this is taking an existing DB with a large amount of data and updating it so that it uses the necessary encoding. Also note that the way this was set up, I have no easy access that I'm aware of to speak with the DB directly: because of security reasons I can't use phpMyAdmin. I've tried installing the mysql server package to see if I could end up writing a SQL UPDATE query that would change the encoding for all the tables, but it doesn't look like it's picking up the existing liferay database for me to use.
Brian Scott Schupbach
RE: Upgrading to UTF-8
June 12, 2013 12:09 PM
Answer

Brian Scott Schupbach

Rank: Expert

Posts: 331

Join Date: October 23, 2008

Recent Posts

I think you can put in the parameter &characterEncoding=utf8 into your jdbc URL
Roger Wilson
RE: Upgrading to UTF-8
June 12, 2013 1:18 PM
Answer

Roger Wilson

Rank: Junior Member

Posts: 29

Join Date: February 20, 2013

Recent Posts

You're referring to something like the following? I've been toying with placing this into my portal-ext.properties:

jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=
jdbc.default.password=


This has been giving me errors so far because it's having issues connecting to the DB -- which is a separate issue, but I didn't want to spend more time on it if it wasn't going to fix the primary problem. Would this resolve UTF-8 character issues in already-existing DBs? I was thinking this might only work if the DB is created from scratch, and that I was going to have to find a way to access the DB directly and run an UPDATE SQL query on its tables (not easy when phpMyAdmin is off-limits).

I actually have Chinese characters working on a local environment, but that uses the Tomcat app server, and this situation is using JBoss 7.x, so this is probably growing out of that discrepancy.