tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Resource Annotation has no effect but JNDI Lookup works (JDBC Resource)
Date Wed, 16 Jun 2010 23:37:05 GMT
-----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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message