you've tried the configuration detailed in the struts faqs?
http://jakarta.apache.org/struts/faqs/database.html

public ActionForward
      execute(ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception
{
javax.sql.DataSource dataSource;
java.sql.Connection myConnection;
try {
 dataSource = getDataSource(request);
 myConnection = dataSource.getConnection();
 // do what you wish with myConnection
} catch (SQLException sqle) {
   getServlet().log("Connection.process", sqle);
} finally {
   //enclose this in a finally block to make
   //sure the connection is closed
   try {
      myConnection.close();
   } catch (SQLException e) {
      getServlet().log("Connection.close", e);
   }
  }
}


From: Philipp Röthl <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Subject: AW: Looking up the Struts Datasource
Date: Fri, 17 Oct 2003 20:01:39 +0200

Ben, thanks for your answer. But the DS I would like to get is the Struts DS. The one I defined in the struts-config.xml.
When I do the naming lookup as you described I get "javax.naming.NameNotFoundException: Name jdbc is not bound in this Context"


Philipp

        -----Ursprüngliche Nachricht-----
        Von: Ben Anderson [mailto:[EMAIL PROTECTED]
        Gesendet: Fr 17.10.2003 16:22
        An: [EMAIL PROTECTED]
        Cc:
        Betreff: Re: Looking up the Struts Datasource



        It depends on the container as to how you put the datasource into the
        context.

        If you're using Tomcat 4.1:
        
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html

        Then to access the datasource:
                String dsName = "java:comp/env/jdbc/myDS";
                ctx = new InitialContext();
                DataSource ds = (DataSource)ctx.lookup(dsName);



>From: Philipp Röthl <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Subject: Looking up the Struts Datasource
>Date: Fri, 17 Oct 2003 15:50:23 +0200
>
>Hi,
>
>I've implemented a struts application that uses JavaBeans which perform the
>whole business logic. These beans access an Oracle DB. The datasource is
>passed from the action classes to the bean classes as a parameter.
>
>Now I have to implement a WebService that does the same as the Struts
>Application. Therefore I use the same JavaBeans.
>
>My problem now is: I have to pass the datasource to the Java Beans. I've
>read that I should be able to access the Struts Datasource via JNDI. But
>how?
>
>Thanks for any help.
>
>Philipp
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


_________________________________________________________________
Cheer a special someone with a fun Halloween eCard from American Greetings!
Go to http://www.msn.americangreetings.com/index_msn.pd?source=msne134



--------------------------------------------------------------------- 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]

_________________________________________________________________
Want to check if your PC is virus-infected? Get a FREE computer virus scan online from McAfee. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



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



Reply via email to