0

I have a problem with recording text to mysql database. In the special charactes have been recorded as ? character.

This is my database.properties

jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:80/image_data/useUnicode=true&characterEncoding=utf-8 jdbc.username=root jdbc.password=

This is my Datasoruce.xml

<?xml version="1.0" encoding="UTF-8"?>

http://www.springframework.org/schema/beans/spring-beans-4.0.xsd ">

<bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
        <value>properties/database.properties</value>
    </property>
</bean>

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
</bean>

Can you help me , How can I set the "useUnicode=yes;characterEncoding=UTF-8;" this code blog? What is my wrong ?

mehfatitem
  • 147
  • 1
  • 12
  • using a mysql client tool the character looks well ? – reos Mar 06 '17 at 21:29
  • I have an error like that. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'image_data/useunicode=true&characterencoding=utf-8' – mehfatitem Mar 06 '17 at 21:33
  • do you use a mysql client tool ? if yes, what is that tool ? – reos Mar 06 '17 at 21:36
  • 2
    The parameters (called "query string") should come after a `?`: `url=jdbc:mysql://localhost:3306/image_data?useUnicode=true&characterEncoding=utf-8` where image_data is the database. The port 80 is for HTML. The default for mysql is 3306. – Joop Eggen Mar 06 '17 at 21:37
  • Thanks. Solved my problem :) – mehfatitem Mar 06 '17 at 22:05

0 Answers0