TransactionException: Error configuring AutoCommit

### Error querying database.  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 57,193,128 milliseconds ago. The last packet sent successfully to the server was 57,193,128 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.

To solve this problem you need to set the poolPingQuery and poolPingEnabled properties in the iBatis config file. For example, see lines 13-14 in code below.

 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
 3 <configuration>
 4 
 5   <environments default="development">
 6       <environment id="development">
 7           <transactionManager type="JDBC" />
 8           <dataSource type="POOLED">
 9               <property name="driver" value="${db.driver}" />
10               <property name="url" value="${db.url}" />
11               <property name="username" value="${db.user}" />
12               <property name="password" value="${db.password}" />
13               <property name="poolPingQuery" value="SELECT NOW()" />
14               <property name="poolPingEnabled" value="true" />
15           </dataSource>
16       </environment>
17   </environments>
18 
19 </configuration>

sql消耗越小越好。

原文地址:https://www.cnblogs.com/TomJay/p/9584798.html