<commit_before>package com.github.davidmoten.email;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;

import com.github.davidmoten.rx.jdbc.Database;

public class DatabaseServlet extends HttpServlet {

	private static final long serialVersionUID = -4137504003076597022L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		try {
			String resource = "java:comp/env/jdbc/flashq";
			Connection con = getConnection(resource);
			Database db = Database.from(con);
			String text = Parameters.toString(req);
			int count = db.update("insert into flashq.entry(text) values(?)")
			// set text parameter
					.parameter(text)
					// get num records inserted
					.count()
					// block and return
					.toBlockingObservable().single();
			System.out.println(count + " records inserted");
			con.close();
		} catch (SQLException e) {
			throw new RuntimeException(e);
		}
	}

	private Connection getConnection(String resource) {
		try {
			Context ctx = new InitialContext();
			DataSource ds = (DataSource) ctx.lookup(resource);
			return ds.getConnection();
		} catch (SQLException e) {
			throw new RuntimeException(e);
		} catch (NamingException e) {
			throw new RuntimeException(e);
		}
	}

}
<commit_msg>return status from db servlet<commit_after>package com.github.davidmoten.email;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;

import com.github.davidmoten.rx.jdbc.Database;

public class DatabaseServlet extends HttpServlet {

	private static final long serialVersionUID = -4137504003076597022L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		try {
			String resource = "java:comp/env/jdbc/flashq";
			Connection con = getConnection(resource);
			Database db = Database.from(con);
			String text = Parameters.toString(req);
			int count = db.update("insert into flashq.entry(text) values(?)")
			// set text parameter
					.parameter(text)
					// get num records inserted
					.count()
					// block and return
					.toBlockingObservable().single();
			System.out.println(count + " records inserted");
			con.close();
		} catch (SQLException e) {
			throw new RuntimeException(e);
		}
		resp.setContentType("text/plain");
		resp.getWriter().write("sid=somebody&status=1");
	}

	private Connection getConnection(String resource) {
		try {
			Context ctx = new InitialContext();
			DataSource ds = (DataSource) ctx.lookup(resource);
			return ds.getConnection();
		} catch (SQLException e) {
			throw new RuntimeException(e);
		} catch (NamingException e) {
			throw new RuntimeException(e);
		}
	}

}

{'fraction_non_alphanumeric': 0.10438356164383561, 'fraction_numerical': 0.010684931506849316, 'mean_word_length': 4.5402124430956, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6344944', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1049, 'n_words': 262}