tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: Accessing resource in WEB-INF outside servlet
Date Mon, 08 Nov 2004 14:35:25 GMT

Hi,

>so how do you handle this? do you pass in the connection info to every
>DAO method, like this:
>public static Book getBook(String connection, String bookId)
>public static void updateBook(String connection, Book book)
>
>that seems tedious, and since the all of my database

You can have the beans get a datasource (from a singleton possibly) and
call its getConnection method.  To encapsulate further, you can just
expose a getConnection method on said singleton.  That way only one
class needs to worry about database configuration.  And you have only
one place to change if you switch from a Class#getResource approach to a
JNDI one or vice versa.

Yoav



This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.


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


Mime
View raw message