@Override
public void config(ComponentConfig config)
{
super.config(config);
// use the security handler to retrieve password
// if it is available.
if (securityHandler == null) {
securityHandler = ContextManager.getSecurityHandler();
}
if (securityHandler != null) {
password = securityHandler.retrievePassword(keyHost, user);
}
try {
dataSource = new OracleConnectionPoolDataSource();
Properties properties = CommonUtil.retrieveStringProperties(systemProperties);;
// process id as current pid
properties.setProperty("oracle.jdbc.v$session.process", String.valueOf(CommonUtil.getPid()));
properties.setProperty("oracle.jdbc.ReadTimeout", String.valueOf(readTimeout * 1000));
properties.setProperty("oracle.net.disableOob", String.valueOf(oracleNetDisableOob));
dataSource.setConnectionProperties(properties);
//dataSource.setDriverClass("oracle.jdbc.OracleDriver");
dataSource.setURL(brokerUrl);
dataSource.setUser(user);
dataSource.setPassword(password);
// the settings below are optional -- c3p0 can work with defaults
//dataSource.setMinPoolSize(initialPoolSize);
//dataSource.setMaxPoolSize(maxPoolSize);
//dataSource.setAcquireIncrement(this.aquireIncrement);
connectionFactory = AQjmsFactory.getConnectionFactory(dataSource);
connections = new CopyOnWriteArrayList<JmsConnection>();
createConnections(this.initialPoolSize);
LOGGER.debug(String.format(
"connection pool initialized with %d connections",
initialPoolSize));
}
catch (JMSException e) {
String error = "Failed to get connectionFactory with error "
+ e.getMessage();
LOGGER.error(error);
throw new InitializationException(error);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
LOGGER.debug(String.format(
"connection pool initialized with %d connections",
initialPoolSize));
// replace cxCode for OracleAQ
if (DEFAULT_JMS_CX_CODE.equals(cxCode)) {
cxCode = "CX610";
}
}
在数据库连接池 编程里使用了copyonwritearrayList
最新推荐文章于 2023-08-31 21:26:25 发布
本文介绍了一个使用Oracle数据库的连接池进行配置的过程。通过设置DataSource的相关属性,如URL、用户名和密码等,并利用securityHandler来获取密码。同时,还设置了连接池的一些高级属性,如读取超时时间和禁用带外(OOB)功能。最后初始化了连接工厂和连接池。
摘要由CSDN通过智能技术生成