I don't follow you -- shouldn't I be able to create an instance of a naming
context and populate it from within my App, then refer back to it?  For this
app, I don't mind hard coding the parameters, it's just that I have a class
called DataStore that contains all the access points to the persistence
layer of my web app.  The DataStore class knows nothing about Tomcat.

Surely I can use some other JNDI provider and "fool" the DataStore class
into talking to it... In fact, here is the single point of reference to the
database resource:

    // Return DataSource via JNDI with object named in
Constants.DATABASE_KEY
    public static javax.sql.DataSource getDs() throws java.sql.SQLException
{
        javax.sql.DataSource ds = null;

        try {
            // Obtain our environment naming context
            javax.naming.Context initCtx = new
javax.naming.InitialContext();
            javax.naming.Context envCtx = (javax.naming.Context)
initCtx.lookup("java:comp/env");

            // Look up our data source
            String check = Constants.DATABASE_KEY;
            ds = (javax.sql.DataSource)
envCtx.lookup(Constants.DATABASE_KEY);
        } catch (javax.naming.NamingException e) {
            e.printStackTrace();
            return null;
        }
        return ds;
    }

What else can I use as a JNDI provider?
----- Original Message ----- 
From: "Shapira, Yoav" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, October 21, 2003 11:01 AM
Subject: RE: Access Tomcat-declared Resource from outside Tomcat



Howdy,
Currently tomcat doesn't have an external JNDI provider, so you can't
really do what you're looking for.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Ian Hunter [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, October 21, 2003 10:50 AM
>To: [EMAIL PROTECTED]
>Subject: Access Tomcat-declared Resource from outside Tomcat
>
>I've got a database resource declared as part of Tomcat's resource pool
>(JNDI?) -- I need a standalone Java app to access it.  How do I declare
>such
>a thing in a standalone app?
>
>I realize this is slightly off topic but I figured someone else out
there
>might try to do the same thing.
>
>Literally, what I'm doing is creating an "alert" subsystem that at
certain
>times, the OS schedules a batch run, and it queries for certain
conditions
>occurring in database tables, and emails people alerts.
>
>Thanks all!
>
>Ian
>
>
>---------------------------------------------------------------------
>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]


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

Reply via email to