<commit_before>package com.example;

import java.sql.*;

public class DBConn {
  // db settings
  public static final String DBHOST = "localhost";
  public static final String DATABASE = "lms2_development";
  public static final String DBUSER = "lms";
  public static final String DBPASS = "";

  public DBConn() {}

  public Connection get() {
    Connection conn = null;

    try
    {
      Class.forName("org.postgresql.Driver");
      String url = "jdbc:postgresql://" + DBHOST + "/" + DATABASE;
      conn = DriverManager.getConnection(url, DBUSER, DBPASS);
    }
    catch (ClassNotFoundException|SQLException e)
    {
      System.err.println(e.getMessage());
    }

    return conn;
  }
}<commit_msg>[jersey] Update DBConn to return pooled connection<commit_after>package com.example;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.commons.pool2.ObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.dbcp2.ConnectionFactory;
import org.apache.commons.dbcp2.PoolableConnection;
import org.apache.commons.dbcp2.PoolingDataSource;
import org.apache.commons.dbcp2.PoolableConnectionFactory;
import org.apache.commons.dbcp2.DriverManagerConnectionFactory;

public class DBConn {
  // db settings
  public static final String DBHOST = "localhost";
  public static final String DATABASE = "lms2_development";
  public static final String DBUSER = "lms";
  public static final String DBPASS = "";

  public static DataSource dataSource;

  public static Connection get() {
    if (dataSource == null) {
      try {

        Class.forName("org.postgresql.Driver");
        dataSource = setupDataSource();

      } catch (ClassNotFoundException e) {

        System.err.println(e.getMessage());

      }
    }

    Connection conn = null;

    try {

      if (dataSource != null) {
        conn = dataSource.getConnection();
      }

    } catch(SQLException e) {

      System.err.println(e.getMessage());

    }

    return conn;
  }

  private static DataSource setupDataSource() {
    String connectURI = "jdbc:postgresql://"+DBHOST+"/"+DATABASE+"?user="+DBUSER+"&password="+<PASSWORD>+"&ssl=false";

    ConnectionFactory connectionFactory =
      new DriverManagerConnectionFactory(connectURI, null);

    PoolableConnectionFactory poolableConnectionFactory =
      new PoolableConnectionFactory(connectionFactory, null);

    ObjectPool<PoolableConnection> connectionPool =
      new GenericObjectPool<>(poolableConnectionFactory);

    poolableConnectionFactory.setPool(connectionPool);

    return new PoolingDataSource<>(connectionPool);
  }
}
{'fraction_non_alphanumeric': 0.10749907646841522, 'fraction_numerical': 0.0033247137052087182, 'mean_word_length': 3.8530465949820787, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6429477', 'n_tokens_mistral': 788, 'n_tokens_neox': 761, 'n_words': 175}