look at your web.xml file - 

you should have two <servlet> elements there one for DatabaseServlet and the
other for ActionServlet. each of them has a <load-on-startup> element.

set the load-on-startup element of the actionservlet to 1 and that of
databaseservlet to 2. to indicate that the database servlet should be loaded
first.

-----Original Message-----
From: Ying Teng
To: Gogineni, Pratima
Sent: 5/4/01 12:10 PM
Subject: RE: database connection

I tried that. The ServletContext object does not have that attribute. If
you
look at the servlet.log file, the system initializes the database first
and
then action, datasource. So I am wondering how to let the system
initializes
the datasourc first so in the databaseServlet class, we can have access
to
the datasource.

My idea is to enable the system to write the database info to the
database.xml file when the database is initialized.

Thanks.

-----Original Message-----
From: Gogineni, Pratima [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 04, 2001 3:00 PM
To: 'Ying Teng '; '[EMAIL PROTECTED] '
Subject: RE: database connection



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