in the databaseservlet class do: getServletContext().getAttribute(key);
-----Original Message-----
From: Ying Teng
To: [EMAIL PROTECTED]
Sent: 5/4/01 8:17 AM
Subject: RE: database connection

Yes, I can get the DataSource reference in the ServletContext object of
the
ActionServlet class. But I want to get the reference to the dataSource
in
the DatabaseServlet class. Can anyone tell me how to get the reference
to
the dataSource from the databaseServlet class? Thanks.

Ying

-----Original Message-----
From: Vivek Bhaskaran [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 03, 2001 5:21 PM
To: [EMAIL PROTECTED]
Subject: Re: database connection


A reference to the DataSource is stored in the ServletContext object...
You
can get it from that.

----- Original Message -----
From: "Ying Teng" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 03, 2001 11:28 AM
Subject: RE: database connection


>
> What you described is true. Now my question is how to get the
datasource
> without referencing the actionServlet. I wanted to intialize the
database
> hashtable of the databaseServlet class in the databaseServlet init
function.
> In order to do that, I need to get the datasource. But I can not
reference
> the actionServlet because the action is initialized after the database
is
> initialized (as in the log file). Hope someone can give me some hints.
> Thanks.
>
> Ying
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 02, 2001 3:10 PM
> To: [EMAIL PROTECTED]
> Subject: RE: database connection
>
>
>
> You will add the key information to the datasource info in you
> struts-config.xml file  it will look like this:
> <data-sources>
>     <data-source
>       key="[some name I'll use to reference this datasource]"
>        autoCommit="false"
>        description="Data Source Configuration"
>        driverClass="org.gjt.mm.mysql.Driver"
>        maxCount="4"
>        minCount="2"
>        password="pass"
>
> url
>
="jdbc:mysql://bethsoft.dev.zenimax.com:3306/test?user=user&password=pas
s
> "
>        user="user"
>     />
>   </data-sources>
>
> Then, after that's done, the easiest way to access it is to reference
it
by
> the action servlet (servlet),  because using actionServlet you can
just do
> servlet.findDataSource("the name you called your datasource")  and
voila,
> you have your datasource object.  From that datasource object you can
> create a connection.
> If you cannot access the actionServlet, then it's a little more
> difficult--and actually I wouldn't be able to help much there, but at
least
> your question would then be "how do I get the datasource without
> referencing the actionServlet"
>
> -Dallas
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

Reply via email to