在学习Spring JDBC的时候进行数据库表数据insert操作的时候,报错:
java.sql.SQLException:Illegal connection port [email protected]: 3306'
java.sql.SQLException:Unknown initial character set index '255' received from server
第一个报错后来检查,可能是url中包含的信息与配置中的重复,发生冲突,第二个报错是修改了配置中的url后,显示未知的字符集。
解决方案:
- 在配置的url中配置字符编码:
?useUnicode=true&characterEncoding=utf8
<property name="url" value="jdbc:mysql://localhost:3306/user_db?useUnicode=true&characterEncoding=utf8"></property>
最终效果:
日志显示操作记录,并且成功修改了一条记录。