Using the <data-source> element in your struts-config.xml file does *not* support the use of JNDI to retrieve it. JNDI is only used for data sources managed by your container. For Tomcat 4.1, for example, see:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html The instructions for setting up your web.xml file, and for accessing the data source in a program, are portable across any container that supports JNDI based data sources. The administrative stuff to configure them is specific to the container. To access your <data-source> from an Action, you'd simply say (Struts 1.1): DataSource ds = getDataSource(request, "FIELDSTONE"); Craig On 5 Jan 2003, Nick Torenvliet wrote: > Date: 05 Jan 2003 21:34:48 -0500 > From: Nick Torenvliet <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: Re: getting a datasource in a bean > > Sounds like a plan,I've never worked with javax.naming packages before > though, I've got the following datasource > > > <data-source type="org.apache.commons.dbcp.BasicDataSource" > key="FIELDSTONE"> > > <set-property > > property="autoCommit" > > value="false"/> > > <set-property > > property="description" > > value="Example Data Source Configuration"/> > > <set-property > > property="driverClassName" > > value="org.gjt.mm.mysql.Driver"/> > > <set-property > > property="maxCount" > > value="4"/> > > <set-property > > property="minCount" > > value="2"/> > > <set-property > > property="password" > > value=""/> > > <set-property > > property="url" > > value="jdbc:mysql://localhost:3306/wessuc"/> > > <set-property > > property="username" > > value="root"/> > > </data-source> > > Cound you give me some example code that uses JNDI to get a connection? > > ~/nick > > > On Sun, 2003-01-05 at 17:46, Max Kremer wrote: > > You can just look up the JNDI datasource in your bean. > > ----- Original Message ----- > > From: "Nick Torenvliet" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Sunday, January 05, 2003 4:51 PM > > Subject: getting a datasource in a bean > > > > > > > Hi, Just as in the examples on the struts site I've succesfully > > > configured a mysql datasource and had it print the results of queries > > > from out of an action class. I am using struts 1.1-b2. > > > > > > I want to replace my current dbpooling(I wrote last year)with the struts > > > datasource and dbcp, I am having one problem though. I can't get a > > > connection in my beans to the database because I have no access to the > > > getDataSource(request,key) method. Since my pooling methods were hard > > > wired I just went in to the database by passing a database name to the > > > methods. > > > > > > The stock answer is to pass a connection to the bean, but that means > > > I'll be rewriting a lot of code. > > > > > > How can I access the datasource from a bean? > > > > > > ~/nick > > > > > > > > > -- > > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > > - > > > > > > > > > > > > -- > > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>