I use something like this
OCIConfig is the configuration read from struts-config.xml


public class OCIPlugin implements PlugIn{
protected static Log log = LogFactory.getLog(OCIPlugin.class);
public void init(ActionServlet servlet,ModuleConfig config) throws
ServletException{
try{
OracleOCIConnectionPool ocp = createPool(readDBConfig(config));
AppContainer cont =
(AppCont)servlet.getServletContext().getAttribute(Constants.APP_CONTAINER);
if(cont == null){
cont   = new LegisContainer();
 servlet.getServletContext().setAttribute(Constants.APP_CONTAINER,cont);
}
cont.setPool(ocp);
}catch(Exception sqex){
log.fatal(sqex);
}
}
private OCIConfig readDBConfig(ModuleConfig config) throws Exception{
PlugInConfig[] pl = config.findPlugInConfigs();
OCIConfig dbconf = null;
if(pl.length > 0){
for(int i=0;i< pl.length;i++){
PlugInConfig p = pl[i];
if(p.getClassName().endsWith("OCIPlugin")){
Map m = p.getProperties();
dbconf = new OCIConfig();
BeanUtils.populate(dbconf, m);
}
}
}
if((dbconf == null)){
throw new Exception("No parameters for pool");
} 
return dbconf;
}
        
private OracleOCIConnectionPool createPool(OCIDBConfig cfg) throws SQLException{
OracleOCIConnectionPool ocp = new OracleOCIConnectionPool();
ocp.setServerName(cfg.getServerName());
ocp.setDatabaseName(cfg.getDatabaseName());
ocp.setDriverType("oci");
ocp.setPortNumber(Integer.parseInt(cfg.getPortNumber()));
ocp.setUser(cfg.getUser());
ocp.setPassword(cfg.getPassword());
Properties props = new Properties();
props.put(OracleOCIConnectionPool.CONNPOOL_MIN_LIMIT,cfg.getMinLimit());
props.put(OracleOCIConnectionPool.CONNPOOL_MAX_LIMIT,cfg.getMaxLimit());
props.put(OracleOCIConnectionPool.CONNPOOL_INCREMENT,cfg.getIncrement());
props.put(OracleOCIConnectionPool.CONNPOOL_TIMEOUT,cfg.getTimeout());
props.put(OracleOCIConnectionPool.CONNPOOL_NOWAIT,cfg.getNowait());
ocp.setPoolConfig(props);
return ocp;
}
public void destroy(){
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = OCIPlugin.class.getClassLoader();
}
try {
LogFactory.release(classLoader);
} catch (Throwable t) {}        
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to