一、问题

用spring jdbcTemplate 向mysql写数据时,中文在数据库中是乱码,mysql库的字符集是utf-8
01-spring jdbcTemplate 写入数据库乱码

二、解决方案

仔细检查了代码,发现mysql配置dataSource时没有指明数据库的字符集
01-spring jdbcTemplate 写入数据库乱码
01-spring jdbcTemplate 写入数据库乱码

解决方案是将url后添加上数据库的字符集为utf-8
01-spring jdbcTemplate 写入数据库乱码

至此问题解决

相关文章:

  • 2022-01-01
  • 2021-09-30
  • 2021-11-22
  • 2022-12-23
  • 2021-05-24
  • 2021-11-09
  • 2021-12-24
猜你喜欢
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
相关资源
相似解决方案