×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




What are you sharing this connection with? Using JNDI is great
if you have two components that don't know about each other,
but there is a lot of overhead involved. You might consider
creating your own cache for connections and putting a reference
to them into a static locator. You can wrap that around your
initial context if necessary to give you the best of both worlds.
If I were to guess, I would say in your second example you used
the wrong name in your lookup.

David Morris

>>> apinsky@aeropostale.com 12/13/02 10:30AM >>>
This is a multi-part message in MIME format.
--
--
[ Picked text/plain from multipart/alternative ]
Hi,
I'm trying to configure Tomcat to use UDBDConnectionPoolDataSource as
statement pooled connection factory and can't get JNDI to work.
Before run it under Tomcat I want to make sure that JNDI portion of the
code would work. The code is:




import java.sql.*;
import javax.naming.*;
import java.util.*;
import com.ibm.db2.jdbc.app.UDBDataSource;


public class UDBDataSourceExample1
{
    public static void main(java.lang.String[] args)
    throws Exception
    {
        UDBDataSource ds = new UDBDataSource();
        ds.setDescription("Basic DataSource");
        System.out.println("dataSource created");


        Context ctx = new InitialContext();


        ctx.rebind("BaseDataSource", ds);
    }
}

Error message when trying to rebind:
javax.naming.NoInitialContextException:
Need to specify class name in environment or system property, or as an
applet parameter, or in an application resource file:
java.naming.factory.initial
....

and if I'm running the same code with initial context set as:

import java.sql.*;
import javax.naming.*;
import java.util.*;
import com.ibm.db2.jdbc.app.UDBDataSource;
public class UDBDataSourceExample1
{
    public static void main(java.lang.String[] args)
    throws Exception
    {
        UDBDataSource ds = new UDBDataSource();
        ds.setDescription("Basic DataSource");
        System.out.println("dataSource created");
        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "com.sun.jndi.fscontext.RefFSContextFactory");
        env.put(Context.PROVIDER_URL, "file:/jdbc/DataSources");
        System.out.println("envelope created");

        // Establish a JNDI context.
        Context ctx = new InitialContext(env);
        System.out.println("Context created");
        ctx.rebind("BaseDataSource", ds);
    }
}
javax.naming.NameNotFoundException; remaining name
'"/jdbc/DataSources"'
      java/lang/Throwable.<init>()V+4 (Throwable.java:78)
      java/lang/Exception.<init>()V+1 (Exception.java:29)
      javax/naming/NamingException.<init>()V+1
(NamingException.java:112)
      javax/naming/NameNotFoundException.<init>()V+1
(NameNotFoundException.java 44...

We are running V5R1 with all latest PTF installed and I run second
example with fscontext.jar included in class path


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.