I want to use connection pool with JPA/TopLink in my web app running on tomcat.Earlier I use jdbc's Connection and Statement classes to manipulate data in database; to use connection pool in that way I simply declare resource in context.xml and get this resource in application:
Context c = new InitialContext();
DataSource source = (DataSource) ((Context)c.lookup("java:comp/env")).lookup("jdbc/MySource");
And now I want to use such connection pool with JPA. How can i do this?
One more question: I've seen in some examples that the reosurce is declared in context.xml and then it is declared in web.xml in < resource-ref>. Why I should declare it in different places or is it the same declaration, I mean is it an equivalent of declaration in context.xml?