Configure MYSQL to use UTF8 with Spring/Hibernate
Submitted by softologi on Sat, 10/10/2009 - 03:28
I started using MySQL in a project that i started working on,
The project uses Hibernate and Spring
and the problem was that strings end up as question marks in the database
adding the following lines in hibernate.cfg.xml
<property name="connection.characterEncoding">utf8</property>
<property name="connection.useUnicode">true</property> did not work!
The problem was solved when i added
"?useUnicode=true&characterEncoding=utf-8"
to the connection URL in the application context file
see block:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/dbname?useUnicode=true&characterEncoding=utf-8" />
<property name="username" value="user" />
<property name="password" value="pass" />
</bean>
