You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Pietro Romanazzi <p....@ct.rupar.puglia.it> on 2011/08/29 15:13:19 UTC

Getting a Database connection

Dear All,
with the Avalon deployment of james (2.3.2) I used the following code to get a db connection within a mailet:
                    ServiceManager serviceManager = (ServiceManager) 
this.mailetContext.getAttribute(Constants.AVALON_COMPONENT_MANAGER);
                    
                    // Get the DataSourceSelector block
                    DataSourceSelector ds = (DataSourceSelector) 
serviceManager.lookup(DataSourceSelector.ROLE);
                    DataSourceComponent dc = (DataSourceComponent) ds.select("maildb");
                    conn = dc.getConnection();
	       ...
	       ...

Has anyone tried the same thing with Spring deployment?
Thanks and regards,

Pietro




---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Getting a Database connection

Posted by Norman Maurer <no...@googlemail.com>.
Hi there,

just use @Resource annotation to injectit.

something like:

@Resource(name = "datasource")

bye
norman

Am Montag, 29. August 2011 schrieb Pietro Romanazzi <
p.romanazzi@ct.rupar.puglia.it>:
> Dear All,
> with the Avalon deployment of james (2.3.2) I used the following code to
get a db connection within a mailet:
>                    ServiceManager serviceManager = (ServiceManager)
> this.mailetContext.getAttribute(Constants.AVALON_COMPONENT_MANAGER);
>
>                    // Get the DataSourceSelector block
>                    DataSourceSelector ds = (DataSourceSelector)
> serviceManager.lookup(DataSourceSelector.ROLE);
>                    DataSourceComponent dc = (DataSourceComponent)
ds.select("maildb");
>                    conn = dc.getConnection();
>               ...
>               ...
>
> Has anyone tried the same thing with Spring deployment?
> Thanks and regards,
>
> Pietro
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>