Hi,
When you configure these datasources in server.xml, you give them names.
You then use these names to do the JNDI lookup.

Alternatively, if you don't know the names or don't want to hard-code
them, you could use Context#listBindings.  Then iterate through all of
them and see which ones you can cast to a DataSource or the DBCP
implementation class for the DataSource.  Then it's simple to use the
DBCP API.

Nothing here is Tomcat-specific.  If you're not familiar with the JNDI
API, it's a Sun Specification and you can find information on it in
various J2EE tutorials and books.  If you're not familiar with the DBCP
API, see the site at http://jakarta.apache.org/commons/dbcp.

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>Sent: Monday, July 26, 2004 9:06 AM
>To: [EMAIL PROTECTED]
>Subject: RE: Tomcat config - query
>
>
>Hi,
>   I want to get all the datasource names and their corresponding urls.
>Say if there are
>4 datasources with there corresponding urls using java without parsing
>config file.
>
>Datasource1      11.122.333.12.1
>Datasource2     11.122.333.12.2
>Datasource3      11.122.333.12.3
>Datasource4      11.122.333.12.4
>
>Is threre some of doing like this using Some tomcat API ? Please help
>with some sample code/snippets.
>
>
>Regards,
>
>shyam
>
>
>-----Original Message-----
>From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
>
>Sent: Monday, July 26, 2004 6:23 PM
>To: Tomcat Users List
>Subject: RE: Tomcat config - query
>
>
>Hi,
>Once you can the DataSource reference via JNDI, you could cast it
>explicitly to your DBCP class, and call the DBCP API methods to obtain
>all the information you want about the pool, including the URL and
such.
>
>Yoav Shapira
>Millennium Research Informatics
>
>
>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>>Sent: Monday, July 26, 2004 8:48 AM
>>To: [EMAIL PROTECTED]
>>Subject: Tomcat config - query
>>
>>
>>Hi,
>>   I am using tomcat4.1.30 with oracle 8.0i . I have one query regards
>
>>to tomcat configuration file. I  want to read datasource name and
>
>>connection url from the config file without parsing  config
>
>>file(parser). Is there any way to read config data using some API
using
>
>>java. Is there any API available  with tomcat catalina.Can you please
>
>>help me out by providing sample code/snippets?
>>
>>
>>regards,
>>shyam
>>
>>
>>
>>
>>Confidentiality Notice
>>
>>
>>The information contained in this electronic message and any
>attachments to
>>this message are intended
>>for the exclusive use of the addressee(s) and may contain confidential
>or
>>privileged information. If
>>you are not the intended recipient, please notify the sender at Wipro
>or
>>[EMAIL PROTECTED] immediately
>>and destroy all copies of this message and any attachments.
>>
>>---------------------------------------------------------------------
>>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]
>
>
>
>
>
>Confidentiality Notice
>
>
>The information contained in this electronic message and any
attachments to
>this message are intended
>for the exclusive use of the addressee(s) and may contain confidential
or
>privileged information. If
>you are not the intended recipient, please notify the sender at Wipro
or
>[EMAIL PROTECTED] immediately
>and destroy all copies of this message and any attachments.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


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

Reply via email to