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;
}