在我们日常开发中,可能会出现使用数据库连接池连接数据库后访问数据库,对数据库数据进行改变后可能会出现中文乱码问题,在这里就来解决一下。
<c3p0-config>
<default-config>
<property name="user">root</property>
<property name="password">1234</property>
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql://localhost:3306/tsms?useUnicode=true&characterEncoding=utf-8</property>
<property name="idleConnectionTestPeriod">30</property>
<property name="initialPoolSize">1</property>
<property name="maxIdleTime">30</property>
<property name="maxPoolSize">20</property>
<property name="minPoolSize">1</property>
<property name="maxStatements">50</property>
</default-config>
</c3p0-config>
在jdbc连接数据库的地方加上?useUnicode=true&characterEncoding=utf-8即可