Sure Craig, I guess it's a good idea to look beyond the weekend..;) 
Thanks for the advice!
Geeta

> -----Original Message-----
> From: Craig McClanahan [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 16, 2004 12:16 PM
> To: Struts Users Mailing List
> Subject: Re: About datasource
> 
> 
> Geeta Ramani wrote:
> 
> >Hi:
> >
> >I think this is the sort of thing you may be looking for:
> >
> >Context ctx = new InitialContext();
> >org.apache.commons.dbcp.BasicDataSource ds =
> >             
> (org.apache.commons.dbcp.BasicDataSource)ctx.lookup("java:comp
> /env/jdbc/yourDB"));
> >
> >  
> >
> 
> That's definitely the sort of code to use when you want to 
> pull things 
> out of JNDI, but I would suggest one small change -- use the generic 
> interface (javax.sql.DataSource) instead of hard coding the 
> implementation class that the current version of Tomcat currently 
> happens to use (o.a.c.d.BasicDataSource).  This will protect you from 
> future changes that Tomcat might make, or if you ever needed to move 
> your app to a different server.
> 
> Doing this, the above code would become:
> 
>     Context ctx = new InitialContext();
>     DataSource ds = (DataSource) 
> ctx.lookup("java:comp/env/jdbc/yourDB");
> 
> For those using Tomcat, there's pretty extensive documentation on the 
> Tomcat web site about how to set up JNDI resources (including 
> the code 
> snippet above :-):
> 
>     
> http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources
> -howto.html
>     
> http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasourc
> e-examples-howto.html
> 
> >Regards,
> >Geeta
> >  
> >
> Craig
> 
> >     
> >
> >  
> >
> >>-----Original Message-----
> >>From: Koon Yue Lam [mailto:[EMAIL PROTECTED]
> >>Sent: Friday, July 16, 2004 5:18 AM
> >>To: Struts Users Mailing List
> >>Subject: Re: About datasource
> >>
> >>
> >>Hi, after some thinking, I have another problem, ^^
> >>If I am using an Action (which extent the Struts' Action 
> class), I can
> >>get the Datasource by calling getDataSource()
> >>But now I want to write my own data assess object which shouldn't
> >>extent Action, I don't know what way I can get the 
> datasource from the
> >>pool.....
> >>
> >>any help??
> >>
> >>Regards
> >>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>    
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to