Java Web プロジェクトで接続タイムアウトを回避するために、Tomcat のネイティブ接続プーリング機能を試してみましたが、まだうまくいかないようです。
フォルダーに入れmysql-connector-java-5.1.23-bin.jar、次のように作成しました:WEB-INF/libMETA-INF/context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Resource name="jdbc/TheDatabase" auth="Container"
            type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"
            maxActive="100" maxIdle="30" maxWait="1000"
            poolPreparedStatements="true" maxOpenPreparedStatements="100"
            username="user" password="pass"
            url="jdbc:mysql://localhost:3306/my_database"/>
</Context>
これが私がすることです:
public static init() {
    ...
    sqlDataSource = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/TheDatabase");
    ...
}
public static ArrayList<ResultSet> dbRead() {
    Connection conn = sqlDataSource.getConnection();
    Statement stmt = null;
    try {
        stmt = conn.createStatement();
        ResultSet res = stmt.executeQuery("SELECT * FROM the_table");
        ...
        res.close();
        return out;
    } catch (SQLException e) {
        // Logging stuff
        return null;
    } finally {
        if (stmt != null)
            try {if (!stmt.isClosed()) stmt.close();}
            catch (SQLException e) {/* Logging stuff */}
        if (conn != null)
            try {if (!conn.isClosed()) conn.close();}
            catch (SQLException e) {/* Logging stuff */}
    }
}
が通過しdbReadた後に関数を呼び出すたびに、次のようになります。wait_timeout
Communications link failure
The last packet successfully received from the server was 1.818.697 milliseconds
ago. The last packet sent successfully to the server was 0 milliseconds ago.
SQL状態で08S01。
締め方が間違っているからだと思っていたのですが、そうではないようです。