String tableName = datasourceName.substring(pos + 1);
datasourceName = datasourceName.substring(0, pos);
Connection conn = null;
if (getInitParameter("source_column") == null) {
throw new MailetException("source_column not specified for JDBCAlias");
}
if (getInitParameter("target_column") == null) {
throw new MailetException("target_column not specified for JDBCAlias");
}
try {
ComponentManager componentManager = (ComponentManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
// Get the DataSourceSelector block
DataSourceSelector datasources = (DataSourceSelector)componentManager.lookup(DataSourceSelector.ROLE);
// Get the data-source required.
datasource = (DataSourceComponent)datasources.select(datasourceName);
conn = datasource.getConnection();
// Check if the required table exists. If not, complain.
DatabaseMetaData dbMetaData = conn.getMetaData();
// Need to ask in the case that identifiers are stored, ask the DatabaseMetaInfo.
// Try UPPER, lower, and MixedCase, to see if the table is there.
if (! ( tableExists(dbMetaData, tableName) ||
tableExists(dbMetaData, tableName.toUpperCase()) ||
tableExists(dbMetaData, tableName.toLowerCase()) )) {
throw new MailetException("Could not find table '" + tableName + "' in datasource '" + datasourceName + "'");
}
//Build the query
query = "SELECT " + getInitParameter("target_column")
+ " FROM " + tableName + " WHERE "