//package com.cisdi.data.DIClient.gateway;
//
//import org.apache.commons.dbcp2.BasicDataSourceFactory;
//
//import javax.security.auth.login.Configuration;
//import javax.sql.DataSource;
//import java.sql.Connection;
//import java.sql.SQLException;
//import java.util.Properties;
//
//public class MysqlPool {
//    private String driver;
//    private String url;
//    private String username;
//    private String password;
//    private Long removeTimeOut;
//    private int maxTotal;
//
//    private DataSource dataSource=null;
//
//    public MysqlPool(String driver, String url, String username, String password, Long removeTimeOut, int maxTotal) {
//        this.driver = driver;
//        this.url = url;
//        this.username = username;
//        this.password = password;
//        this.removeTimeOut = removeTimeOut;
//        this.maxTotal = maxTotal;
//    }
//
//    public boolean init()
//    {
//        Properties properties=new Properties();
//        properties.setProperty("driverClassName",driver);
//        properties.setProperty("url",url);
//        properties.setProperty("username",username);
//        properties.setProperty("password",password);
//        properties.setProperty("initialSize",String.valueOf(maxTotal));
//        properties.setProperty("maxTotal",String.valueOf(maxTotal));
//        properties.setProperty("maxIdle",String.valueOf(maxTotal/2));
//        properties.setProperty("minIdle",String.valueOf(maxTotal/4));
//        properties.setProperty("maxWaitMillis",String.valueOf(1000));
//        properties.setProperty("removeAbandonedTimeout",String.valueOf(removeTimeOut));
//        properties.setProperty("removeAbandonedOnMaintenance",String.valueOf(true));
//        properties.setProperty("removeAbandonedOnBorrow",String.valueOf(true));
//        try {
//            dataSource= BasicDataSourceFactory.createDataSource(properties);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return false;
//    }
//    public Connection getConnection()
//    {
//        Connection connection=null;
//        try
//        {
//            connection=dataSource.getConnection();
//            connection.setAutoCommit(false);
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
//        return connection;
//    }
//}
