You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Javier Campoamor <jc...@lapize.com> on 2002/02/25 20:18:50 UTC
RE: Accessing database defined in struts-config
Some days ago, Antony made a question and now I'm having the same problem,
can some one explain to me if there is a way to access to the datasource
configured in the struts-config file from a class that doesn't extend an
action?
Thanks in advance
Javier
> -----Mensaje original-----
> De: Antony Stace [mailto:s45652001@yahoo.com]
> Enviado el: miercoles 30 de enero de 2002 5:36
> Para: struts-user@jakarta.apache.org
> Asunto: Accessing database defined in struts-config
>
>
> Hi
>
> I have an initialisation servlet which is run when my web app start up.
>
> public class WebAppInit extends HttpServlet
> {
> public void init()
> {
>
> }
>
> }
>
> All it does is to set some application wide beans. I need to be able to
> access the database I have defined in my struts-config.xml file
> in this initalisation servlet. I
> can access this database from my Action classes via
>
> public final class Logon extends Action
> {
>
> public ActionForward perform(ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response)
> throws IOException, ServletException
> {
> DataSource dataSource = servlet.findDataSource("testDataBase");
>
> }
> }
>
>
> since this class extents Action but do not know how to access
> this database
> via the WebAppInit class. How can I access the database from the
> WebAppInit class.
>
>
>
> --
>
>
> Cheers
>
> Tony
> ---------------------------------------------------------------------
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>