mysql休眠,休眠mysqlčć

Im having problem when i try to save Patient with familyname = 'Lučić' in MYSQL database using hibernate + jpa.

When i do regular INSERT INTO, letter č and ć are displayed correctly in database and on my jsf form, so im sure that charset on my form is correct and in database.

Here is my hibernate configuration:

app_persistance.dialect=org.hibernate.dialect.MySQLDialect

app_persistance.show_sql=true

app_persistance.generateDdl=true

app_persistance.minPoolSize=1

app_persistance.maxPoolSize=10

app_persistance.connection.url=jdbc:mysql://localhost:3306/dentapp

app_persistance.connection.username=root

app_persistance.connection.password=root

app_persistance.connection.driver_class=com.mysql.jdbc.Driver

app_persistance.hibernate.connection.CharSet=utf8_croatian_ci

app_persistance.hibernate.connection.characterEncoding=UTF-8

app_persistance.hibernate.connection.useUnicode=true

app_persistance.hbm2ddl=update

I tryed to debug and check if value familyname in Patient object from jsf form has right values ( č, ć ) in serviceImpl:

@Override

@Transactional

public Patient save(Patient patient) {

return patientDAO.save(patient);

}

but everything seems to be fine in patient object so it has to be some problem with hibernate configuration. When hibernate+jpa is saving patient to db, it converts č,ć to ?? characters.

Can anyone point me to something, where i should look/read/check ?

Thanks !

解决方案

It seems that your connection is not using UTF8

Change

app_persistance.connection.url=jdbc:mysql://localhost:3306/dentapp

to

app_persistance.connection.url=jdbc:mysql://localhost:3306/dentapp?useUnicode=true&characterEncoding=utf-8

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值