struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Edgar P. Dollin" <ed...@blue-moose.net>
Subject RE: dataSources outside of actionservlet
Date Tue, 17 Dec 2002 16:18:04 GMT
            Context env = (Context) new
InitialContext().lookup("java:comp/env");
            DataSource ds = (DataSource) env.lookup("yourconnection");
            conn = ds.getConnection();

Edgar
-----Original Message-----
From: Mark [mailto:marklowe@libero.it] 
Sent: Tuesday, December 17, 2002 10:13 AM
To: Struts Users Mailing List
Subject: Re: dataSources outside of actionservlet


I know that , i've read that .. But I what i really want to know is this

Without importing any servlet stuff

Some_means_of_getting_to_details_in_config_xml.getDatasource(mykey);

Many thanks mark

On 17-12-2002 15:17, "Edgar P. Dollin" <edgar@blue-moose.net> wrote:

> Another option is to aquire the database connection via jndi when you 
> need it.
> 
> Edgar
> 
> -----Original Message-----
> From: Matthias Bauer [mailto:Matthias.Bauer@livinglogic.de]
> Sent: Tuesday, December 17, 2002 9:05 AM
> To: 'Struts Users Mailing List'
> Subject: Re: FW: dataSources outside of actionservlet
> 
> 
> The normal thing to is the following: You aquire a database connection

> in the action class and pass it on as a parameter to the bean's 
> database
> 
> methods.
> 
> --- Matthias
> 
> Mark wrote:
> 
>> Sorry to repost this question, but the more i think about it the more

>> i
> 
>> think it a reasonable one (please tell me if i'm wrong).
>> 
>> 
>> ------ Forwarded Message
>> From: "Mark Lowe" <marklowe@libero.it>
>> Reply-To: "Struts Users Mailing List" 
>> <struts-user@jakarta.apache.org>
>> Date: Tue, 17 Dec 2002 09:03:33 +0100
>> To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
>> Subject: dataSources outside of actionservlet
>> 
>> hello
>> 
>> you'll all have to forgive my stupidity but i've been having real 
>> problems trying to reference the datasource specified in config.xml 
>> in my business logic classes.
>> 
>> I've been very good and seperated everything as one should. but i 
>> really need a straight answer to this (i.e. an example that works).
>> 
>> "For maximum code re-use, business logic beans should be designed and

>> implemented so that they do not know they are being executed in a web

>> application environment"
>> 
>> now i've only seen examples referencing the datasource inside an 
>> action
> 
>> servlet, this appears to go against the design pattern. So how do i 
>> do this? have i neglected to find the correct example? why are all 
>> the examples of how to reference the datasource breaking the 
>> aforementioned
> 
>> priciple? please i'm very confused ..
>> 
>> many thanks in advance
>> 
>> mark
>> 
>> 
>> 
>> 
>> --
>> To unsubscribe, e-mail: 
>> <mailto:struts-user-unsubscribe@jakarta.apache.org>
>> For additional commands, e-mail: 
>> <mailto:struts-user-help@jakarta.apache.org>
>> 
>> 
>> 
>> ------ End of Forwarded Message
>> 
>> 
>> --
>> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
>> For additional commands, e-mail: 
>> <mailto:struts-user-help@jakarta.apache.org>
>> 
>>  
>> 
> 
> 
> --
> To unsubscribe, e-mail: 
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:struts-user-help@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:struts-user-help@jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message