DataSource can be obtained either Deployment descriptor as
"java:comp/jdbc/MyDataSource"
(associate a Jndi name to the Datasource
)


----- Original Message -----
From: Andreas Leitner <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; 'Aapo Laakkonen'
<[EMAIL PROTECTED]>
Sent: Wednesday, July 25, 2001 3:29 PM
Subject: DataSource and Factories


>
> Hi again,
>
> I would like to seperate my buisness logic from the data layer. Say I
> have an object Person, that has the fields id, firstName and lastName.
> The only constructor I provide is one which takes two arguments (id,
> firstName and lastName). The person objects will be stored in a certain
> Database, but this may change in the future, this is why I use a
> factory. The factory takes an id, connects to the DB, retrieves the
> data, creates the Person object and returns it.
>
> This pattern also comes in handy, when you have classes that inherit
> from Person. If the DB access would happen in the constructor, one could
> only create Person objects, with a factory, you can create an object of
> the real type instead.
>
> Anyway, what I want is to get a DataSource without knowing about a
> servlet. Is this somehow possible? Is there some static access to the
> DataSource Repository?
>
> Tia,
> Andreas
>

Reply via email to