Chris; This example is not mean that put your database architecture on top of this :) Just shows that container injects the resource if you use container aware class.
Otherwise stick with JPA :) Thanks; --Gurkan ________________________________ From: Christopher Schultz <ch...@christopherschultz.net> To: Tomcat Users List <users@tomcat.apache.org> Sent: Thu, June 17, 2010 2:37:05 AM Subject: Re: Resource Annotation has no effect but JNDI Lookup works (JDBC Resource) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gurkan, On 6/16/2010 10:44 AM, Gurkan Erdogdu wrote: > Please define some servlet and try with it, > > class TestClass extends HttpServlet{ > > private @Resource(name="jdbc/TestDb") DataSource datasource; > > @PostConstruct > public void postConstruct(){ > //Check datasource here > } > } While this example appears to work, I might recommend to the reader that using a JDBC DataSource directly in a servlet should probably be considered poor architecture. I would recommend putting your data-fetching logic in a support class, which will be easier to test and maintain over time. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwZYCEACgkQ9CaO5/Lv0PCi9QCeNZoqsj8I+H+1XI4tOWgzomyE /FgAn1EqT6y+9v7Hbwcdt7n2yRo5mDCD =GpeJ -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org