We are to enable UTF-8 character encoding to our web application designed using JSF2.0, Hibernate, MySQL.
Following is the datasource defined in our application context file
<bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/dbname" />
<property name="maxPoolSize" value="10" />
<property name="maxStatements" value="0" />
<property name="minPoolSize" value="5" />
<property name="useUnicode" value="yes" />
<property name="characterEncoding" value="UTF-8" />
</bean>
While running the application we are getting exception
Error creating bean with name 'SessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'DataSource' Error creating bean with name 'DataSource' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invalid property 'useUnicode' of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: Bean property 'useUnicode' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
We have also tried using the following but get an error
<bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/dbname?useUnicode=yes&characterEncoding=UTF-8;" />
<property name="maxPoolSize" value="10" />
<property name="maxStatements" value="0" />
<property name="minPoolSize" value="5" />
</bean>
Error: The reference to entity "characterEncoding" must end with the ';' delimiter