Hi Matthias,

Thanks for all the info.

As you said that only one can be defined without a key hence if I use
getDataSource(req);  then it should use the default datasource without
me having to specify the Globals.DATA_SOURCE_KEY as the second parameter.
So looking at my struts-config.xml there is only one datasource hence my
reading is that the second parameter is redundant. Also
Globals.DATA_SOURCE_KEY is showing as deprecated so I was avoiding using
it.

Looking at it further I see that part of my problem was that I am using
JBuilder X which adds a key by default, once that key is added
DATA_SOURCE_KEY doesn't work, so obviously the key is the
problem. Once I remove the key I can use the single parameter.

Thanks for your help!

Chris

On Wed, 7 Jan 2004, Matthias Wessendorf wrote:

> hi Chris!
>
> only one can be defined without a key
>
> it is stored under default:
> Globals.DATA_SOURCE_KEY
>
> and of cource
> in struts 1.2 you must!!! specify a type
>
> in 1.1 it is a "legacy"-class
> GenericDataSource (by default)
> this is to remove...A
>
> you must say then type="org.apache.commons.dbcp.BasicDataSource"
>
> for that you must
> add two jars
> -the DBCP-commons from http://jakarta.apache.org/commons/dbcp/
> -the pool-jar from: http://jakarta.apache.org/commons/pool/
>
> for more read:
> http://jakarta.apache.org/struts/faqs/database.html
>
> regards,
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 07, 2004 10:44 AM
> To: Struts Users Mailing List
> Subject: RE: Datasource problem
>
>
> Thanks Mathias, just after I sent the email I got it working using the
> key as you suggested.  I tried using the key earlier today and it didn't
> work, probably I had some other problem which I accidentally fixed and
> now I've confused myself.
>
> Shouldn't it work without the key since I only have the one datasource
> and all the docs I've seen don't require the key. My understanding is
> that the key is only required when there is more than one datasource.
> No?
>
> Thanks for your help.
>
> Chris
>
>
> On Wed, 7 Jan 2004, Matthias Wessendorf wrote:
>
> > hi chris,
> >
> > have you tried:
> >
> > getDataSource(req,"dataSource");
> >
> >
> > greetings
> >
> >
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, January 07, 2004 10:25 AM
> > To: [EMAIL PROTECTED]
> > Subject: Datasource problem
> >
> >
> > Hi,
> >
> > I must be missing something here but for the life of me I cannot see
> > what it is. I've search the mail archives and can't find anything the
> > same, also I checked 3 different books and it looks like I have
> > everything configured correctly, I also tried two diffent MySQL
> > drivers.
> >
> > I have added a datasource to my struts-config and when I run the
> > application I can see it initializes ok:
> >
> > Jan 7, 2004 10:09:48 PM org.apache.struts.legacy.GenericDataSource
> > createConnection
> > INFO:    createConnection()
> > Jan 7, 2004 10:09:49 PM org.apache.struts.legacy.GenericDataSource
> > createConnection
> > INFO:    createConnection()
> >
> > If I mess up the password I get an access denied error on the db when
> > this runs so that tells me I am getting a connection.
> >
> > But when I try to access the datasource inside my action using the
> > following code:
> >
> > DataSource dataSource = getDataSource(req);
> >
> > dataSource returns null which is where I'm stumped.
> >
> > Anyone get any idea what this might be? I'm using struts 1.1 and tried
>
> > JDK 1.4 and 1.3.
> >
> > Here's my struts-config:
> >
> > <data-sources>
> >   <data-source key="dataSource">
> >     <set-property property="driverClass"
> value="com.mysql.jdbc.Driver"/>
> >     <set-property property="url"
> > value="jdbc:mysql://127.0.0.1:3306/ash"/>
> >     <set-property property="user" value="myusername" />
> >     <set-property property="password" value="mypassword" />
> >     <set-property property="minCount" value="2" />
> >     <set-property property="maxCount" value="4" />
> >   </data-source>
> > </data-sources>
> >
> >
> > The exception is java.lang.NullPointerException which results from
> > trying to use the null dataSource.
> >
> > There is one other compiler error I am getting when I build the
> > project which I still trying to track down:
> >
> > Jan 7, 2004 10:09:48 PM org.apache.commons.digester.Digester error
> > SEVERE: Parse Error at line 19 column -1: Attribute value for "path"
> > is #REQUIRED.
> > org.xml.sax.SAXParseException: Attribute value for "path" is
> #REQUIRED.
> >     at org.apache.crimson.parser.Parser2.error(Parser2.java:3317)
> >     at
> > org.apache.crimson.parser.Parser2.defaultAttributes(Parser2.java:1889)
> >     at
> > org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1600)
> >     at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
> >     at
> > org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
> >     at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
> >     at
> > org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
> >     at
> > org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
> >     at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
> >     at
> > org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
> >     at
> > org.apache.commons.digester.Digester.parse(Digester.java:1548)
> >     at
> > org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionSer
> > vl
> > et.java:1006)
> >     at
> >
> org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.ja
> > va:955)
> >     at
> > org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
> >     at javax.servlet.GenericServlet.init(GenericServlet.java:256)
> >     at
> >
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.jav
> > a:918)
> >     at
> >
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:810)
> >     at
> >
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.j
> > ava:3279)
> >     at
> >
> org.apache.catalina.core.StandardContext.start(StandardContext.java:3421
> > )
> >     at
> > org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
> >     at
> > org.apache.catalina.core.StandardHost.start(StandardHost.java:638)
> >     at
> > org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
> >     at
> > org.apache.catalina.core.StandardEngine.start(StandardEngine.java:343)
> >     at
> >
> org.apache.catalina.core.StandardService.start(StandardService.java:388)
> >     at
> > org.apache.catalina.core.StandardServer.start(StandardServer.java:506)
> >     at org.apache.catalina.startup.Catalina.start(Catalina.java:781)
> >     at
> > org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
> >     at
> > org.apache.catalina.startup.Catalina.process(Catalina.java:179)
> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >     at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> > a:39)
> >     at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> > Impl.java:25)
> >     at java.lang.reflect.Method.invoke(Method.java:324)
> >
> >
> > Thanks for any advice.
> >
> >
> > Chris
> >
> >
> > ---------------------------------------------------------------------
> > 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]
>


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

Reply via email to