<commit_before>package org.t246osslab.easybuggy.troubles;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.SQLTransactionRollbackException;
import java.sql.Statement;
import java.util.Locale;
import java.util.UUID;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.pmw.tinylog.Logger;
import org.t246osslab.easybuggy.utils.ApplicationUtils;
import org.t246osslab.easybuggy.utils.Closer;
import org.t246osslab.easybuggy.utils.HTTPResponseCreator;
import org.t246osslab.easybuggy.utils.MessageUtils;

@SuppressWarnings("serial")
@WebServlet(urlPatterns = { "/deadlock2" })
public class DeadlockServlet2 extends HttpServlet {

    protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

        PrintWriter writer = null;
        try {
            String order = req.getParameter("order");
            Locale locale = req.getLocale();

            StringBuilder bodyHtml = new StringBuilder();
            bodyHtml.append("<form action=\"deadlock2\" method=\"post\">");
            bodyHtml.append(MessageUtils.getMsg("msg.note.sql.deadlock", locale));
            bodyHtml.append("<br><br>");
            bodyHtml.append(MessageUtils.getMsg("label.order", locale) + ": ");
            bodyHtml.append("<input type=\"radio\" name=\"order\" value=\"asc\" checked>");
            bodyHtml.append(MessageUtils.getMsg("label.asc", locale));
            bodyHtml.append("<input type=\"radio\" name=\"order\" value=\"desc\">");
            bodyHtml.append(MessageUtils.getMsg("label.desc", locale));
            bodyHtml.append("<br><br>");
            bodyHtml.append("<input type=\"submit\" value=\"" + MessageUtils.getMsg("label.update", locale) + "\">");
            bodyHtml.append("<br><br>");

            EmbeddedJavaDb2 app = new EmbeddedJavaDb2();
            if ("asc".equals(order)) {
                String message = app.update(new int[] { 1, EmbeddedJavaDb2.MAX_USER_COUNT }, locale);
                bodyHtml.append(message);
            } else if ("desc".equals(order)) {
                String message = app.update(new int[] { EmbeddedJavaDb2.MAX_USER_COUNT, 1 }, locale);
                bodyHtml.append(message);
            } else {
                bodyHtml.append(MessageUtils.getMsg("msg.warn.enter.asc.or.desc", locale));
            }
            bodyHtml.append("</form>");
            HTTPResponseCreator.createSimpleResponse(res, null, bodyHtml.toString());

        } catch (Exception e) {
            Logger.error(e);
        } finally {
            Closer.close(writer);
        }
    }
}

class EmbeddedJavaDb2 {

    static final int MAX_USER_COUNT = 1000;
    static final String dbUrl = ApplicationUtils.getDatabaseURL();
    static final String dbDriver = ApplicationUtils.getDatabaseDriver();

    static {
        Connection conn = null;
        Statement stmt = null;
        try {
            if (dbDriver != null && !dbDriver.equals("")) {
                try {<commit_msg>Change the record count of a table for dead lock servlet.<commit_after>package org.t246osslab.easybuggy.troubles;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.SQLTransactionRollbackException;
import java.sql.Statement;
import java.util.Locale;
import java.util.UUID;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.pmw.tinylog.Logger;
import org.t246osslab.easybuggy.utils.ApplicationUtils;
import org.t246osslab.easybuggy.utils.Closer;
import org.t246osslab.easybuggy.utils.HTTPResponseCreator;
import org.t246osslab.easybuggy.utils.MessageUtils;

@SuppressWarnings("serial")
@WebServlet(urlPatterns = { "/deadlock2" })
public class DeadlockServlet2 extends HttpServlet {

    protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

        PrintWriter writer = null;
        try {
            String order = req.getParameter("order");
            Locale locale = req.getLocale();

            StringBuilder bodyHtml = new StringBuilder();
            bodyHtml.append("<form action=\"deadlock2\" method=\"post\">");
            bodyHtml.append(MessageUtils.getMsg("msg.note.sql.deadlock", locale));
            bodyHtml.append("<br><br>");
            bodyHtml.append(MessageUtils.getMsg("label.order", locale) + ": ");
            bodyHtml.append("<input type=\"radio\" name=\"order\" value=\"asc\" checked>");
            bodyHtml.append(MessageUtils.getMsg("label.asc", locale));
            bodyHtml.append("<input type=\"radio\" name=\"order\" value=\"desc\">");
            bodyHtml.append(MessageUtils.getMsg("label.desc", locale));
            bodyHtml.append("<br><br>");
            bodyHtml.append("<input type=\"submit\" value=\"" + MessageUtils.getMsg("label.update", locale) + "\">");
            bodyHtml.append("<br><br>");

            EmbeddedJavaDb2 app = new EmbeddedJavaDb2();
            if ("asc".equals(order)) {
                String message = app.update(new int[] { 1, EmbeddedJavaDb2.MAX_USER_COUNT }, locale);
                bodyHtml.append(message);
            } else if ("desc".equals(order)) {
                String message = app.update(new int[] { EmbeddedJavaDb2.MAX_USER_COUNT, 1 }, locale);
                bodyHtml.append(message);
            } else {
                bodyHtml.append(MessageUtils.getMsg("msg.warn.enter.asc.or.desc", locale));
            }
            bodyHtml.append("</form>");
            HTTPResponseCreator.createSimpleResponse(res, null, bodyHtml.toString());

        } catch (Exception e) {
            Logger.error(e);
        } finally {
            Closer.close(writer);
        }
    }
}

class EmbeddedJavaDb2 {

    static final int MAX_USER_COUNT = 2;
    static final String dbUrl = ApplicationUtils.getDatabaseURL();
    static final String dbDriver = ApplicationUtils.getDatabaseDriver();

    static {
        Connection conn = null;
        Statement stmt = null;
        try {
            if (dbDriver != null && !dbDriver.equals("")) {
                try {
{'fraction_non_alphanumeric': 0.1305005292605474, 'fraction_numerical': 0.008316951459246939, 'mean_word_length': 2.9747596153846154, 'pattern_counts': {'":': 2, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5629847', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1813, 'n_words': 348}