驱动版本问题
javax.net.ssl.SSLException MESSAGE: closing inbound before receiving peer's close_notifyThe server time zone value ‘?й???’ is unrecognized
解决方法:
mysql8.0 以上的数据库需要修改驱动版本,并且在配置链接数据库的URL时,加上useSSL=false 和 Timezone=GMT%2B8
格式如下:
- driver-class-name:
com.mysql.cj.jdbc.Driver - url:
jdbc:mysql://localhost:3306/your_db_name?serverTimezone=GMT%2B8&useSSL=false
中文问题
数据库编码方式为utf-8,但是使用PreparedStatement插入中文时,插入的结果为”?”
描述:(插入结果为?)
解决方法
在获取数据库连接时,使用characterEncoding参数指明编码方式
url:jdbc:mysql://localhost:3306/your_db_name?characterEncoding=utf8
修改后,preparedStatement的对象的charEncoding属性就是utf-8
否则默认采用 WINDOWS-1252
