Using Weblogic DataSource for configuration.

656 views
Skip to first unread message

Mehmet Kirazoglu

unread,
Nov 17, 2014, 6:13:52 AM11/17/14
to hika...@googlegroups.com
Hello All,

I use HikariCP connection pool through Weblogic's DataSource configuration. With the below configuration, it seems HikariCP retrieving connections from Weblogic and does not release back. I observe, after every stop-start the application, it fills the WL's maximumPoolSize. We have to restart the WL datasource every time in order to flush the current stale connections.

I may increase the maximumPoolSize of WL and wait for the idleTimeout for drop stale connections by theirselves between a start-stop. But my WL guys are not willing to do it. Do you have any suggestions for configuration?

HikariCP maximumPoolSize: default = 10;
Weblogic maximumPoolSize: 15;

Thanks,
Mehmet

    private static final DataSource EAGER_INSTANCE = getHikariDataSource();
   
    private static DataSource getWeblogicDataSource() {
        Context ctx = null;
        Hashtable ht = new Hashtable();
        DataSource ds = null;
        ht.put(Context.INITIAL_CONTEXT_FACTORY, Constants.JNDI_FACTORY);
        ht.put(Context.PROVIDER_URL, Constants.PROVIDER_URL);
        try {
            ctx = new InitialContext(ht);
            ds = (DataSource) ctx.lookup(Constants.DATASOURCE_NAME);
            ctx.close();
        }
        catch (NamingException e) {
            e.printStackTrace();
        }
        return ds;
    }

private static HikariDataSource getHikariDataSource() {
        HikariConfig config = new HikariConfig();
        config.setDataSource(getWeblogicDataSource());
        HikariDataSource hds = new HikariDataSource(config);
        hds.setAutoCommit(false);
        hds.addDataSourceProperty("cachePrepStmts", true);
        hds.addDataSourceProperty("prepStmtCacheSize", Constants.prepStmtCacheSize);
        hds.addDataSourceProperty("prepStmtCacheSqlLimit", Constants.prepStmtCacheSqlLimit);
        hds.addDataSourceProperty("useServerPrepStmts", true);
        hds.setMaximumPoolSize(20);
        return hds;
    }





Jens

unread,
Nov 17, 2014, 6:41:07 AM11/17/14
to hika...@googlegroups.com
        hds.setMaximumPoolSize(20);

By default HikariCP is a fixed connection pool. That means if you set the maximum pool size to 20 then HikariCP will allocate 20 connections and keep them even if they are all idle.

If you also set the minimum pool size then HikariCP will start with minimum pool size connections and adjusts the connection count if needed up to the configured maximum connections.

Just read through the various configuration options at: https://github.com/brettwooldridge/HikariCP

-- J.

Brett Wooldridge

unread,
Nov 17, 2014, 7:33:15 AM11/17/14
to hika...@googlegroups.com
Thanks, Jens!  You have no idea how happy it makes us that members of the community are taking the initiative to answer questions.  We really appreciate it.

Mehmet Kirazoglu

unread,
Nov 17, 2014, 8:31:35 AM11/17/14
to Jens, hika...@googlegroups.com
Hello Jens,

Thank you for your quick response. It seems this is another trade-off issue. I either set the minimumIdle and discard HikariCP control mechanism as fixed connection pool or flush the Weblogic datasource every time.

It's better fly with autopilot.

Mehmet

Mehmet Kirazoglu
linkedin | blog | twitter

--
You received this message because you are subscribed to a topic in the Google Groups "HikariCP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hikari-cp/hOF6oVwJGS4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hikari-cp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages