use of org.opennms.netmgt.config.opennmsDataSources.Param in project opennms by OpenNMS.
the class C3P0ConnectionFactory method initializePool.
@Override
protected void initializePool(final JdbcDataSource dataSource) throws SQLException {
m_pool = new ComboPooledDataSource();
m_pool.setPassword(dataSource.getPassword());
m_pool.setUser(dataSource.getUserName());
m_pool.setJdbcUrl(dataSource.getUrl());
try {
m_pool.setDriverClass(dataSource.getClassName());
} catch (final PropertyVetoException e) {
throw new SQLException("Unable to set driver class.", e);
}
final Properties properties = new Properties();
for (final Param parameter : dataSource.getParamCollection()) {
properties.put(parameter.getName(), parameter.getValue());
}
if (!properties.isEmpty()) {
m_pool.setProperties(properties);
}
}
use of org.opennms.netmgt.config.opennmsDataSources.Param in project opennms by OpenNMS.
the class HikariCPConnectionFactory method initializePool.
/* (non-Javadoc)
* @see org.opennms.core.db.BaseConnectionFactory#initializePool(org.opennms.netmgt.config.opennmsDataSources.JdbcDataSource)
*/
// TODO Enable and configure MetricRegistry
@Override
protected void initializePool(final JdbcDataSource dataSource) throws SQLException {
final Properties properties = new Properties();
for (final Param parameter : dataSource.getParamCollection()) {
properties.setProperty(parameter.getName(), parameter.getValue());
}
final HikariConfig config = new HikariConfig(properties);
config.setPoolName(dataSource.getName());
config.setJdbcUrl(dataSource.getUrl());
config.setUsername(dataSource.getUserName());
config.setPassword(dataSource.getPassword());
config.setDriverClassName(dataSource.getClassName());
// NMS-9387: Block indefinitely when waiting for a connection
config.setConnectionTimeout(0);
// For JMX Monitoring
config.setRegisterMbeans(true);
config.validate();
m_pool = new HikariDataSource(config);
}
use of org.opennms.netmgt.config.opennmsDataSources.Param in project opennms by OpenNMS.
the class DataSourceConfigurationTest method data.
@Parameters
public static Collection<Object[]> data() throws Exception {
DataSourceConfiguration config = new DataSourceConfiguration();
ConnectionPool connectionPool = new ConnectionPool();
connectionPool.setFactory("org.opennms.core.db.HikariCPConnectionFactory");
connectionPool.setIdleTimeout(600);
connectionPool.setLoginTimeout(3);
connectionPool.setMinPool(50);
connectionPool.setMaxPool(50);
connectionPool.setMaxSize(50);
config.setConnectionPool(connectionPool);
JdbcDataSource opennmsDs = new JdbcDataSource();
opennmsDs.setName("opennms");
opennmsDs.setClassName("org.postgresql.Driver");
opennmsDs.setUrl("jdbc:postgresql://localhost:5432/template1");
opennmsDs.setUserName("opennms");
opennmsDs.setPassword("opennms");
config.addJdbcDataSource(opennmsDs);
JdbcDataSource opennmsDeuceDs = new JdbcDataSource();
opennmsDeuceDs.setName("opennms2");
opennmsDeuceDs.setClassName("org.postgresql.Driver");
opennmsDeuceDs.setUrl("jdbc:postgresql://localhost:5432/template1");
opennmsDeuceDs.addParam(new Param("user", "opennms"));
opennmsDeuceDs.addParam(new Param("password", "opennms"));
config.addJdbcDataSource(opennmsDeuceDs);
return Arrays.asList(new Object[][] { { config, new File("src/test/resources/org/opennms/core/db/opennms-datasources.xml") } });
}
Aggregations