首页 > 其他分享 >Mybatis报错解决: Your driver may not support getAutoCommit() or setAutoCommit()

Mybatis报错解决: Your driver may not support getAutoCommit() or setAutoCommit()

时间:2022-11-24 18:02:47浏览次数:43  
标签:setAutoCommit may configured getAutoCommit server 报错 mybatis org


报错信息:

### Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit.  Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 82,940,457 milliseconds ago.  The last packet sent successfully to the server was 82,940,457 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

这个错误是偶尔才发现,解决办法是在mybatis配置文件中加如下配置:

<property name="poolPingQuery" value="SELECT NOW()" />
<property name="poolPingEnabled" value="true" />

完整配置如下:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!--数据源配置 使用mysql数据库 -->
<environments default="aaa">
<environment id="aaa">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<!-- 并发最大连接数 默认10-->
<property name="poolMaximumActiveConnections" value="1000"/>
<property name="driver" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="poolPingQuery" value="SELECT NOW()" />
<property name="poolPingEnabled" value="true" />
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="common-mapper.xml"/>
</mappers>
</configuration>


标签:setAutoCommit,may,configured,getAutoCommit,server,报错,mybatis,org
From: https://blog.51cto.com/u_15890522/5884428

相关文章