MySQL Connector/J UTF-8
Posted by: Richard Harrison
Date: August 25, 2016 07:10PM

I've set up a small project using Struts 2, Tomcat, Eclipselink and MySQL, which needs to store some special characters in the database using UTF-8. I set up the database tables as "utf8_unicode_ci". The EclipseLink persistance.xml file looks like this:

<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/xxxxxx?useUnicode=true&amp;characterEncod‌​ing=UTF-8" />
<property name="javax.persistence.jdbc.user" value="yyyyyyyy" />
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>
<property name="eclipselink.create-ddl-jdbc-file-name" value="datastore-create.sql"/>
<property name="eclipselink.drop-ddl-jdbc-file-name" value="datastore-drop.sql"/>
<property name="eclipselink.application-location" value="/home/richardh/dddd/"/>
<property name="eclipselink.deploy-on-startup" value="false"/>
<property name="javax.persistence.jdbc.password" value="zzzzzzz"/>
</properties>

When special characters are entered through the app, the EclipseLink logs show that the special characters are in the statement as it is logged. However, they aren't in the database correctly. (They show up as "?".) When I take the same statement and manually run it against the database, it works fine. This leads me to believe it's a driver issue, but it looks to me like the setup for the driver URL is also right. If anyone has any ideas, I'd appreciate them.

Thanks,

Richard

Options: ReplyQuote


Subject
Written By
Posted
MySQL Connector/J UTF-8
August 25, 2016 07:10PM
August 26, 2016 05:46AM
August 29, 2016 03:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.