<commit_before>package ascompany.sinfonia.Core;

import ascompany.sinfonia.Configurazione.ConfigName;
import ascompany.sinfonia.UtilitySinfonia.Utility;
import static ascompany.sinfonia.UtilitySinfonia.Utility.convertFileToJson;
import com.google.gson.JsonObject;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 
 * @author m.castano
 */
public class ConnectionCore
{
    /**
     * Oggetto di tipo connection 
     */
    private Connection c = null;
    
    public ConnectionCore openConnectionToDB(String pathDbConfig) throws Exception
    {
        JsonObject DBConfigFile = convertFileToJson(pathDbConfig);
        
        Utility.validateConfigJson(DBConfigFile);
        
        Class.forName(DBConfigFile.get(ConfigName.DRIVER).getAsString());
        c = DriverManager.getConnection
        (
            (
                DBConfigFile.get(ConfigName.IP).getAsString() + ":" + 
                DBConfigFile.get(ConfigName.PORT).getAsString() +"/"+ DBConfigFile.get(ConfigName.DATABASE).getAsString() + ConfigName.PREFIX_TIMEZONE + DBConfigFile.get(ConfigName.TIMEZONE).getAsString()
            ),    
            DBConfigFile.get(ConfigName.USERNAME).getAsString(),
            DBConfigFile.get(ConfigName.PASSWORD).getAsString()
        );
        return this;
    }
    
    public ConnectionCore openConnection(String pathDbConfig) throws Exception
    {
        JsonObject DBConfigFile = convertFileToJson(pathDbConfig);
        Class.forName(DBConfigFile.get(ConfigName.DRIVER).getAsString());
        c = DriverManager.getConnection
        (
            (
                DBConfigFile.get(ConfigName.IP).getAsString() + ":" + 
                DBConfigFile.get(ConfigName.PORT).getAsString() + ConfigName.PREFIX_TIMEZONE + DBConfigFile.get(ConfigName.TIMEZONE).getAsString()
            ),    
            DBConfigFile.get(ConfigName.USERNAME).getAsString(),
            DBConfigFile.get(ConfigName.PASSWORD).getAsString()
        );
        return this;
    }
    
    /**
     * Ricava la connessione d'istanza
     * 
     * @param commitMode modalità in cui viene aperta la connessione per quanto riguarda l'auto commit
     * @throws SQLException 
     */
    public Connection fetchConnection(boolean commitMode) throws SQLException
    {
        c.setAutoCommit(commitMode);
        return getConnection();
    }

    /**
     * 
     * @return Ritorna la connessione
     */
    public Connection getConnection()
    {
        return c;
    }
    
    /**
     * Funzione che chiude la connessione 
     */
    public void closeConnection()
    {<commit_msg>Aggiunto metodo set per la connessione.<commit_after>package ascompany.sinfonia.Core;

import ascompany.sinfonia.Configurazione.ConfigName;
import ascompany.sinfonia.UtilitySinfonia.Utility;
import static ascompany.sinfonia.UtilitySinfonia.Utility.convertFileToJson;
import com.google.gson.JsonObject;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 
 * @author m.castano
 */
public class ConnectionCore
{
    /**
     * Oggetto di tipo connection 
     */
    private Connection c = null;
    
    public ConnectionCore openConnectionToDB(String pathDbConfig) throws Exception
    {
        JsonObject DBConfigFile = convertFileToJson(pathDbConfig);
        
        Utility.validateConfigJson(DBConfigFile);
        
        Class.forName(DBConfigFile.get(ConfigName.DRIVER).getAsString());
        c = DriverManager.getConnection
        (
            (
                DBConfigFile.get(ConfigName.IP).getAsString() + ":" + 
                DBConfigFile.get(ConfigName.PORT).getAsString() +"/"+ DBConfigFile.get(ConfigName.DATABASE).getAsString() + ConfigName.PREFIX_TIMEZONE + DBConfigFile.get(ConfigName.TIMEZONE).getAsString()
            ),    
            DBConfigFile.get(ConfigName.USERNAME).getAsString(),
            DBConfigFile.get(ConfigName.PASSWORD).getAsString()
        );
        return this;
    }
    
    public ConnectionCore openConnection(String pathDbConfig) throws Exception
    {
        JsonObject DBConfigFile = convertFileToJson(pathDbConfig);
        Class.forName(DBConfigFile.get(ConfigName.DRIVER).getAsString());
        c = DriverManager.getConnection
        (
            (
                DBConfigFile.get(ConfigName.IP).getAsString() + ":" + 
                DBConfigFile.get(ConfigName.PORT).getAsString() + ConfigName.PREFIX_TIMEZONE + DBConfigFile.get(ConfigName.TIMEZONE).getAsString()
            ),    
            DBConfigFile.get(ConfigName.USERNAME).getAsString(),
            DBConfigFile.get(ConfigName.PASSWORD).getAsString()
        );
        return this;
    }
    
    /**
     * Ricava la connessione d'istanza
     * 
     * @param commitMode modalità in cui viene aperta la connessione per quanto riguarda l'auto commit
     * @throws SQLException 
     */
    public Connection fetchConnection(boolean commitMode) throws SQLException
    {
        c.setAutoCommit(commitMode);
        return getConnection();
    }

    /**
     * 
     * @return Ritorna la connessione
     */
    public Connection getConnection()
    {
        return c;
    }

    public void setC(Connection c) 
    {
        this.c = c;
    }
    
    
    /**
     * Funzione che chiude la connessione 
     */
    public void closeConnection()
    {
{'fraction_non_alphanumeric': 0.09687034277198212, 'fraction_numerical': 0.0, 'mean_word_length': 2.5462351387054163, 'pattern_counts': {'":': 4, '<': 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': '6960919', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1534, 'n_words': 247}