当前位置: 代码迷 >> J2EE >> mybatis 连接mysql乱码解决思路
  详细解决方案

mybatis 连接mysql乱码解决思路

热度:76   发布时间:2016-04-22 02:31:24.0
mybatis 连接mysql乱码
求高手指教
mybatis 连接mysql时,插入中文数据时乱码,我要更改的是mybatis,数据库是没问题的,其它项目测试过!

mybatis配置片段
driverClass=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://127.0.0.1:3306/mydb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
user=root
password=root
initialPoolSize=10
minPoolSize=5
maxPoolSize=30
acquireIncrement=10
maxIdleTime=10
maxStatements=0


------解决方案--------------------
很有可能是数据源的问题,建议使用org.logicalcobwebs.proxool.ProxoolDataSource作数据源。

<bean id="dataSource"
class="org.logicalcobwebs.proxool.ProxoolDataSource" >
<property name="driverUrl">
<value>${proxool.driver-url}</value>
</property>
<property name="alias">
<value>${proxool.alias}</value>
</property>
<property name="driver">
<value>${proxool.driver-class}</value>
</property>
<property name="user">
<value>${proxool.user}</value>
</property>
<property name="password">
<value>${proxool.password}</value>
</property>
<property name="prototypeCount">
<value>${proxool.prototype-count}</value>
</property>
<property name="maximumConnectionCount">
<value>${proxool.maximum-connection-count}</value>
</property>
<property name="minimumConnectionCount">
<value>${proxool.minimum-connection-count}</value>
</property>
<property name="simultaneousBuildThrottle">
<value>${proxool.simultaneous-build-throttle}</value>
</property>
<property name="trace">
<value>${proxool.trace}</value>
</property>
<property name="verbose">
<value>${proxool.verbose}</value>
</property>
</bean>



#proxool connection pool
proxool.driver-class=com.mysql.jdbc.Driver
proxool.prototype-count=5
proxool.maximum-connection-count=100
proxool.minimum-connection-count=10
proxool.simultaneous-build-throttle=100
proxool.trace=false
proxool.verbose=true
proxool.user=root
proxool.password=root
proxool.driver-url=jdbc:mysql://127.0.0.1/xxxxxxxdb?useUnicode=true&characterEncoding=utf8&autoReconnect=true
proxool.alias=wooophone_mpyeah_db

mybatis.config=classpath:mybatis/mybatis-config.xml





  相关解决方案