@@ -0,0 +1,3131 @@
+package org.t246osslab.easybuggy.troubles;%0A%0Aimport java.io.IOException;%0Aimport java.io.PrintWriter;%0Aimport java.sql.Connection;%0Aimport java.sql.DriverManager;%0Aimport java.sql.SQLException;%0Aimport java.sql.Statement;%0Aimport java.util.Locale;%0A%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.annotation.WebServlet;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0Aimport org.pmw.tinylog.Logger;%0Aimport org.t246osslab.easybuggy.utils.ApplicationUtils;%0Aimport org.t246osslab.easybuggy.utils.Closer;%0Aimport org.t246osslab.easybuggy.utils.MessageUtils;%0A%0A@SuppressWarnings(%22serial%22)%0A@WebServlet(urlPatterns = %7B %22/dbconnectionleak%22 %7D)%0Apublic class DBConnectionLeakServlet extends HttpServlet %7B%0A%0A    static final String dbUrl = ApplicationUtils.getDatabaseURL();%0A    static final String dbDriver = ApplicationUtils.getDatabaseDriver();%0A    boolean isLoad = false;%0A%0A    protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException %7B%0A%0A        PrintWriter writer = null;%0A        Connection conn = null;%0A        Statement stmt = null;%0A        Locale locale = req.getLocale();%0A        try %7B%0A            res.setCharacterEncoding(%22UTF-8%22);%0A            res.setContentType(%22text/plain%22);%0A            writer = res.getWriter();%0A%0A            if (dbDriver != null && !dbDriver.equals(%22%22)) %7B%0A                try %7B%0A                    Class.forName(%22com.mysql.jdbc.Driver%22);%0A                %7D catch (ClassNotFoundException e) %7B%0A                    Logger.error(e);%0A                %7D%0A            %7D%0A            conn = DriverManager.getConnection(dbUrl);%0A            stmt = conn.createStatement();%0A            if (!isLoad) %7B%0A                isLoad = true;%0A                try %7B%0A                    stmt.executeUpdate(%22drop table users3%22);%0A                %7D catch (SQLException e) %7B%0A                    // ignore exception if exist the table%0A                %7D%0A                // create and insert users table%0A                stmt.executeUpdate(%22create table users3 (id int primary key, name varchar(30), password varchar(100))%22);%0A            %7D%0A            stmt.executeUpdate(%22insert into users3 select count(*)+1, 'name', 'password' from users3%22);%0A            writer.println(MessageUtils.getMsg(%22msg.db.connection.leak.occur%22, locale));%0A%0A        %7D catch (SQLException e) %7B%0A            Logger.error(e);%0A            writer.println(MessageUtils.getMsg(%22msg.unknown.exception.occur%22, locale));%0A            writer.println(e.getLocalizedMessage());%0A        %7D finally %7B%0A            Closer.close(writer);%0A            /* A DB connection leaks because the following lines are commented out.%0A            if (stmt != null) %7B%0A                try %7B%0A                    stmt.close();%0A                %7D catch (SQLException e) %7B%0A                    Logger.error(e);%0A                %7D%0A            %7D%0A            if (conn != null) %7B%0A                try %7B%0A                    conn.close();%0A                %7D catch (SQLException e) %7B%0A                    Logger.error(e);%0A                %7D%0A            %7D%0A             */%0A        %7D%0A    %7D%0A%7D%0A

Add a servlet which can cause DB connection leaks.