<commit_before>package edu.mit.kc.wlrouting.txn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

import edu.mit.kc.wlrouting.WLProperties;
import edu.mit.kc.wlrouting.WLPropertyKeys;

public class WLConnectionManager {
	static private WLConnectionManager instance;
	private static Connection connection;
	static private DataSource ds ;
	private static final String dbString = "jdbc:oracle:thin:@(description=(address=(host=coeus-traindb.mit.edu)(protocol=tcp)(port=1521))(connect_data=( SERVICE_NAME = COEUSQA.Coeus-TrainDB.mit.edu)(server=DEDICATED)))";
	private static final String userid = "youssefn";
	private static final String pwd = "<PASSWORD>";
//	private static final String dbString = "jdbc:oracle:thin:@(description=(address=(host=osp-award.mit.edu)(protocol=tcp)(port=1521))(connect_data=(SID=OSPA)(server=DEDICATED)))";
//	private static final String userid = "ospa";
//	private static final String pwd = "<PASSWORD>";

	public static synchronized WLConnectionManager getInstance(){
		if (instance == null) {
            instance = new WLConnectionManager();
        }
        return instance;
	}
	
	private WLConnectionManager(){
		try{
			String connectionMode = WLProperties.getProperty(WLPropertyKeys.CONNECTION_MODE);
			if(connectionMode.equals("DATASOURCE")){
				String jndiName = WLProperties.getProperty(WLPropertyKeys.DS_JNDI_NAME);            
	            Properties p = new Properties();
	            Context envContext;
	            Context initContext = new InitialContext();
	            envContext  = (Context)initContext.lookup("java:comp/env");
	            ds = (DataSource)envContext.lookup(jndiName);
			}
        }catch(Exception e) {
           e.printStackTrace();
        }
	}
	public Connection getConnection() throws SQLException{
		String connectionMode = WLProperties.getProperty(WLPropertyKeys.CONNECTION_MODE);
        Connection con = null ;
        if(connectionMode.equals("DATASOURCE")){
	        if(ds!=null){
	        	con = ds.getConnection();
	        }else{
	        	throw new RuntimeException("Datasource is null");
	        }
        }else{
        	con = getConnectionLocal();
        }
        return con;        
    }
	public void close(Connection conn){
		try{
			if(connection==null){
				conn.close();
			}else{
				conn.commit();
			}
		}catch(SQLException ex){
			ex.printStackTrace();
		}
	}
	public Connection getConnectionLocal(){
		
		try {
			if(connection!=null && !connection.isClosed()){
				return connection;
			}else{
				return DriverManager.getConnection(dbString,userid,pwd);
			}
		} catch (SQLException e) {
			if(connection!=null){
				try {
					connection.close();
				} catch (SQLException e1) {
					e1.printStackTrace();
				}
				connection=null;
			}
			e.printStackTrace();
		}
		return null;
	}

	public void distroyConnection() {
		try {
			if(connection!=null && !connection.isClosed()){
				connection.close();
				connection=null;
			}
		}catch(SQLException ex){
			connection=null;
		}
	}
}
<commit_msg>masked the pwd<commit_after>package edu.mit.kc.wlrouting.txn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

import edu.mit.kc.wlrouting.WLProperties;
import edu.mit.kc.wlrouting.WLPropertyKeys;

public class WLConnectionManager {
	static private WLConnectionManager instance;
	private static Connection connection;
	static private DataSource ds ;
	private static final String dbString = "jdbc:oracle:thin:@(description=(address=(host=coeus-traindb.mit.edu)(protocol=tcp)(port=1521))(connect_data=( SERVICE_NAME = COEUSQA.Coeus-TrainDB.mit.edu)(server=DEDICATED)))";
	private static final String userid = "ergfdhfgdh";
	private static final String pwd = "<PASSWORD>";
//	private static final String dbString = "jdbc:oracle:thin:@(description=(address=(host=osp-award.mit.edu)(protocol=tcp)(port=1521))(connect_data=(SID=OSPA)(server=DEDICATED)))";
//	private static final String userid = "ospa";
//	private static final String pwd = "<PASSWORD>";

	public static synchronized WLConnectionManager getInstance(){
		if (instance == null) {
            instance = new WLConnectionManager();
        }
        return instance;
	}
	
	private WLConnectionManager(){
		try{
			String connectionMode = WLProperties.getProperty(WLPropertyKeys.CONNECTION_MODE);
			if(connectionMode.equals("DATASOURCE")){
				String jndiName = WLProperties.getProperty(WLPropertyKeys.DS_JNDI_NAME);            
	            Properties p = new Properties();
	            Context envContext;
	            Context initContext = new InitialContext();
	            envContext  = (Context)initContext.lookup("java:comp/env");
	            ds = (DataSource)envContext.lookup(jndiName);
			}
        }catch(Exception e) {
           e.printStackTrace();
        }
	}
	public Connection getConnection() throws SQLException{
		String connectionMode = WLProperties.getProperty(WLPropertyKeys.CONNECTION_MODE);
        Connection con = null ;
        if(connectionMode.equals("DATASOURCE")){
	        if(ds!=null){
	        	con = ds.getConnection();
	        }else{
	        	throw new RuntimeException("Datasource is null");
	        }
        }else{
        	con = getConnectionLocal();
        }
        return con;        
    }
	public void close(Connection conn){
		try{
			if(connection==null){
				conn.close();
			}else{
				conn.commit();
			}
		}catch(SQLException ex){
			ex.printStackTrace();
		}
	}
	public Connection getConnectionLocal(){
		
		try {
			if(connection!=null && !connection.isClosed()){
				return connection;
			}else{
				return DriverManager.getConnection(dbString,userid,pwd);
			}
		} catch (SQLException e) {
			if(connection!=null){
				try {
					connection.close();
				} catch (SQLException e1) {
					e1.printStackTrace();
				}
				connection=null;
			}
			e.printStackTrace();
		}
		return null;
	}

	public void distroyConnection() {
		try {
			if(connection!=null && !connection.isClosed()){
				connection.close();
				connection=null;
			}
		}catch(SQLException ex){
			connection=null;
		}
	}
}

{'fraction_non_alphanumeric': 0.12143195079640436, 'fraction_numerical': 0.0031540766440624505, 'mean_word_length': 3.481978798586572, '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': '3142602', 'n_tokens_mistral': 2100, 'n_tokens_neox': 1856, 'n_words': 376}