Search in sources :

Example 61 with HikariConfig

use of com.zaxxer.hikari.HikariConfig in project opentheso by miledrousset.

the class Soap method openConnexionPool.

private HikariDataSource openConnexionPool(Properties properties) {
    HikariConfig config = new HikariConfig();
    config.setMinimumIdle(Integer.parseInt(properties.getProperty("minimumIdle")));
    config.setMaximumPoolSize(Integer.parseInt(properties.getProperty("setMaximumPoolSize")));
    config.setAutoCommit(true);
    config.setIdleTimeout(Integer.parseInt(properties.getProperty("idleTimeout")));
    config.setConnectionTimeout(Integer.parseInt(properties.getProperty("connectionTimeout")));
    config.setConnectionTestQuery(properties.getProperty("connectionTestQuery"));
    config.setDataSourceClassName(properties.getProperty("dataSourceClassName"));
    config.addDataSourceProperty("user", properties.getProperty("dataSource.user"));
    config.addDataSourceProperty("password", properties.getProperty("dataSource.password"));
    config.addDataSourceProperty("databaseName", properties.getProperty("dataSource.databaseName"));
    config.addDataSourceProperty("serverName", properties.getProperty("dataSource.serverName"));
    config.addDataSourceProperty("portNumber", properties.getProperty("dataSource.serverPort"));
    HikariDataSource poolConnexion1 = new HikariDataSource(config);
    try {
        Connection conn = poolConnexion1.getConnection();
        if (conn == null)
            return null;
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_FATAL, ex.getClass().getName(), ex.getMessage());
        FacesContext.getCurrentInstance().addMessage(null, message);
        poolConnexion1.close();
        return null;
    }
    return poolConnexion1;
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) SQLException(java.sql.SQLException) Connection(java.sql.Connection) HikariConfig(com.zaxxer.hikari.HikariConfig) Connexion(mom.trd.opentheso.bdd.helper.Connexion) FacesMessage(javax.faces.application.FacesMessage)

Example 62 with HikariConfig

use of com.zaxxer.hikari.HikariConfig in project opentheso by miledrousset.

the class GetAllArkTest method openConnexionPool.

private HikariDataSource openConnexionPool() {
    HikariConfig config = new HikariConfig();
    config.setMinimumIdle(1);
    config.setMaximumPoolSize(1000);
    config.setConnectionTestQuery("SELECT 1");
    config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
    /*    config.addDataSourceProperty("user", "opentheso");
         config.addDataSourceProperty("password", "opentheso");
         config.addDataSourceProperty("databaseName", "OTW");
         */
    config.addDataSourceProperty("user", "pactols");
    config.addDataSourceProperty("password", "pactols");
    config.addDataSourceProperty("databaseName", "pactols");
    // config.addDataSourceProperty("serverName", "localhost");
    config.addDataSourceProperty("portNumber", "5433");
    config.addDataSourceProperty("serverName", "localhost");
    // config.addDataSourceProperty("serverName", "193.48.137.88");
    HikariDataSource poolConnexion1 = new HikariDataSource(config);
    return poolConnexion1;
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) HikariConfig(com.zaxxer.hikari.HikariConfig)

Example 63 with HikariConfig

use of com.zaxxer.hikari.HikariConfig in project opentheso by miledrousset.

the class ConnexionTest method openConnexionPool.

private HikariDataSource openConnexionPool() {
    HikariConfig config = new HikariConfig();
    config.setMinimumIdle(1);
    config.setMaximumPoolSize(100);
    config.setConnectionTestQuery("SELECT 1");
    config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
    // Zoomathia
    config.addDataSourceProperty("user", "pactols");
    config.addDataSourceProperty("password", "pactols");
    config.addDataSourceProperty("databaseName", "pactols");
    config.addDataSourceProperty("portNumber", "5433");
    config.addDataSourceProperty("serverName", "localhost");
    /*      config.addDataSourceProperty("user", "pactols");
        config.addDataSourceProperty("password", "pactols");
        config.addDataSourceProperty("databaseName", "OTW");
         */
    /*
        config.addDataSourceProperty("user", "pactols");
        config.addDataSourceProperty("password", "frantiq2014");
        config.addDataSourceProperty("databaseName", "pactols");

      //  config.addDataSourceProperty("serverName", "localhost");
        /*config.addDataSourceProperty("portNumber", "5433");
        config.addDataSourceProperty("serverName", "localhost");
        //    config.addDataSourceProperty("serverName", "193.48.137.88");
         */
    HikariDataSource poolConnexion1 = new HikariDataSource(config);
    return poolConnexion1;
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) HikariConfig(com.zaxxer.hikari.HikariConfig)

Example 64 with HikariConfig

use of com.zaxxer.hikari.HikariConfig in project opentheso by miledrousset.

the class ImportNotesTest method openConnexionPool.

private HikariDataSource openConnexionPool() {
    HikariConfig config = new HikariConfig();
    config.setMinimumIdle(1);
    config.setMaximumPoolSize(100);
    config.setConnectionTestQuery("SELECT 1");
    config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
    // Zoomathia
    /*        config.addDataSourceProperty("user", "opentheso");
        config.addDataSourceProperty("password", "opentheso");
        config.addDataSourceProperty("databaseName", "zoo");
        config.addDataSourceProperty("portNumber", "5433");
        config.addDataSourceProperty("serverName", "localhost");
*/
    /*      config.addDataSourceProperty("user", "pactols");
        config.addDataSourceProperty("password", "pactols");
        config.addDataSourceProperty("databaseName", "OTW");
         */
    config.addDataSourceProperty("user", "pactols");
    config.addDataSourceProperty("password", "frantiq2014");
    config.addDataSourceProperty("databaseName", "pactols_test");
    config.addDataSourceProperty("portNumber", "5432");
    config.addDataSourceProperty("serverName", "pactols2.mom.fr");
    // config.addDataSourceProperty("serverName", "localhost");
    /*config.addDataSourceProperty("portNumber", "5433");
        config.addDataSourceProperty("serverName", "localhost");
        //    config.addDataSourceProperty("serverName", "193.48.137.88");
         */
    HikariDataSource poolConnexion1 = new HikariDataSource(config);
    return poolConnexion1;
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) HikariConfig(com.zaxxer.hikari.HikariConfig)

Example 65 with HikariConfig

use of com.zaxxer.hikari.HikariConfig in project opentheso by miledrousset.

the class TestExportTabulate method openConnexionPool.

private HikariDataSource openConnexionPool() {
    HikariConfig config = new HikariConfig();
    config.setMinimumIdle(1);
    config.setMaximumPoolSize(1000);
    // config.setJdbc4ConnectionTest(false);
    config.setConnectionTestQuery("SELECT 1");
    config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
    /*   config.addDataSourceProperty("user", "opentheso");
         config.addDataSourceProperty("password", "opentheso");
         config.addDataSourceProperty("databaseName", "OTW");
         */
    config.addDataSourceProperty("user", "pactols");
    config.addDataSourceProperty("password", "frantiq2014");
    config.addDataSourceProperty("databaseName", "pactols");
    // config.addDataSourceProperty("serverName", "localhost");
    config.addDataSourceProperty("portNumber", "5432");
    config.addDataSourceProperty("serverName", "opentheso.mom.fr");
    // config.addDataSourceProperty("serverName", "193.48.137.88");
    HikariDataSource poolConnexion1 = new HikariDataSource(config);
    return poolConnexion1;
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) HikariConfig(com.zaxxer.hikari.HikariConfig)

Aggregations

HikariConfig (com.zaxxer.hikari.HikariConfig)136 HikariDataSource (com.zaxxer.hikari.HikariDataSource)109 Test (org.junit.Test)82 TestElf.newHikariConfig (com.zaxxer.hikari.pool.TestElf.newHikariConfig)79 Connection (java.sql.Connection)41 StubConnection (com.zaxxer.hikari.mocks.StubConnection)29 SQLException (java.sql.SQLException)26 Properties (java.util.Properties)11 StubDataSource (com.zaxxer.hikari.mocks.StubDataSource)9 PoolInitializationException (com.zaxxer.hikari.pool.HikariPool.PoolInitializationException)6 FacesMessage (javax.faces.application.FacesMessage)6 DataSource (javax.sql.DataSource)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Statement (java.sql.Statement)5 PrintStream (java.io.PrintStream)4 PreparedStatement (java.sql.PreparedStatement)4 Connexion (mom.trd.opentheso.bdd.helper.Connexion)4 MetricRegistry (com.codahale.metrics.MetricRegistry)3 TestElf.newHikariDataSource (com.zaxxer.hikari.pool.TestElf.newHikariDataSource)3 File (java.io.File)3