以前にMySQLのコネクションが8時間放置すると切れる問題で挫折していたのですが
今回、対処法を聞いたので、設定中。

以前は、URLの引数に「autoReconnect=true」を追加することで、この現象を防ごうと
していたのですが、それでは思う結果が得られなかったので。。。

(以前の設定)
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="com.mysql.jdbc.Driver" />
<property name="JDBC.ConnectionURL" value="jdbc:mysql://localhost:3306/hogehoge?characterEncoding=UTF-8&characterEncoding=UTF-8" />
・・・(以下略)




こんな感じでURLの末尾に書くんではうまくいかなくて、次の形で設定を変えてみました。

(途中省略)
<property name="Pool.TimeToWait" value="10000" />
<property name="Pool.PingQuery" value="select 0" />
<property name="Pool.PingEnabled" value="true" />
<property name="Pool.PingConnectionsOlderThan" value="1800000" />
<property name="Pool.PingConnectionsNotUsedFor" value="1800000" />



時間の設定とか、イマイチよくわかってなくて、どれくらいが適切なのかは
調べるなりしないといけないんですが、これでうまくいけばいいなぁ。。



ちなみに、これってdataSource type="SIMPLE"の部分をDBCPとかにすると
Pool.PingQueryのとこがvalidationQueryになったりとか、微妙に設定変わるのですが、
今回はdataSourceのtypeを変えずに対応してみました。

設定するパラメータとか、本家のドキュメント見ても日本語がしっくりこなくて
以下のサイトにお世話になりました。
iBATISについて①


今回の件とか、作った当時の自分の適当加減がうかがえます。
残念すぎる。


ちょっとずつ良くして行こう。。。



(追記)
上記の設定を仕込んで、20時間ほど放置してから再接続してみました。
したらば以下のログが。
2009-10-12 15:22:31,006 WARN [TP-Processor24] (JakartaCommonsLoggingImpl.java:31) - Execution of ping query 'select 0' failed: The last packet successfully received from the server was73988 seconds ago.The last packet sent successfully to the server was 73988 seconds ago, which 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.


・・・何結局「autoReconnect=true」するのかぃ。あとここで言うところの「values for client timeouts」って何だろか。
これが8時間のことなのか。んー・・・。

もうちょっと調べる必要がありますが、指示通り、「autoReconnect=true」を再設定してみます。



(さらに追記)
「values for client timeouts」は、my.cnfの中のwait_timeoutのことらしい。
そして、「autoReconnect=true」を

(抜粋)
<property name="JDBC.ConnectionURL" value="jdbc:mysql://localhost:3306/hogehoge?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true" />


と、追加して再度チャレンジ。
が、前回と同様の警告文。。。 書き方間違ってるんかな。