In James version 2.3, we expose database connections via the javax.sql.DataSource. This document describes how to update code using James previous database connectivity (Avalon's DataSourceComponent).
import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource;
ComponentManager componentManager = (ComponentManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER); // Get the DataSourceSelector service DataSourceSelector datasources = (DataSourceSelector)componentManager.lookup(DataSourceSelector.ROLE); // Get the data-source required. datasource = (DataSourceComponent)datasources.select(datasourceName);
InitialContext ctx = new InitialContext(); datasource = (DataSource) ctx.lookup("java:comp/env/jdbc/" + datasourceName);