/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package DataLayer;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.dbcp2.BasicDataSource;
import DataLayer.settings;

/**
 *
 * @author install1
 */
public class DBCPDataSourceHLstats {

    private static BasicDataSource ds = new BasicDataSource();
    static {
        try {
            ds.setDriver(new com.mysql.cj.jdbc.Driver());
            ds.setUrl(settings.hlURL);
            ds.setUsername(settings.hlusername);
            ds.setPassword(settings.hlpassword);
            ds.setMaxTotal(-1);
            ds.setMinIdle(5);
            ds.setMaxIdle(-1);
            ds.setMaxOpenPreparedStatements(100);
        } catch (SQLException ex) {
            Logger.getLogger(DBCPDataSource.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static Connection getConnection() throws SQLException {
        return ds.getConnection();
    }

    private DBCPDataSourceHLstats() {
    }
}
