時間がなくて、つい、やってしまう過ちなのだが、
mybatis を使ったサイトを構築して、以下のエラーを発生
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error opening session. 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 168,172,795 milliseconds ago.
The last packet sent successfully to the server was 168,172,796 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.
WebコンテナのJDBC Pool を利用して修正するよりも
mybatis の Configuration.xml の方を修正した方が手っ取り早い。
mybatis の Configuration.xml で、
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="JNDI">
<property name="data_source" value="java:comp/env/jdbc/xxxx"/>
</dataSource>
</environment>
</environments>
と、書いていたのを廃止して、以下のようにする。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
"">http://ibatis.apache.org/dtd/ibatis-3-config.dtd">
<configuration>
<environments default="deployment">
<environment id="deployment">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/xxxxdb" />
<property name="username" value="xxxxxxx" />
<property name="password" value="xxxxxxx" />
<property name="poolPingQuery" value="SELECT 1 FROM DUAL" />
<property name="poolPingEnabled" value="true" />
<property name="poolMaximumActiveConnections" value="15" />
<property name="poolMaximumIdleConnections" value="15" />
<property name="poolTimeToWait" value="20000" />
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="sqlmap.xml"/>
</mappers>
</configuration>