james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Charles <e...@apache.org>
Subject Re: opening database connection in custom mailet
Date Sat, 05 Jan 2013 15:18:06 GMT
Hi,

You should be able to use the jpa entityManagerFactory by defining a 
field in your mailet

@PersistenceUnit
private EntityManagerFactory entityManagerFactory;

Invoke in your code to get an entityManager:
EntityManager entityManager = entityManagerFactory.createEntityManager();

This will be configured based on the james-database.properties file.

 From there, it's plain JPA, where plain JDBC is also supported 
(entityManager.createNativeQuery).

Thx, Eric


On 05/01/2013 15:35, Rajender Vallapureddy wrote:
> Hi Eric,
>
> I have a requirement where I need to open database connection within
> my custom mailet. Is there any connection API within james that I can
> use and make queries to the database.
>
>
> Would appreciate your help :)
>
> Thank you,
> Regards,
> Rajender
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>

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


Mime
View raw message