LDAP/JNDI auto reconnect ?

Discussion in 'Java' started by sony.antony@gmail.com, Oct 18, 2006.

  1. Guest

    Hello:

    We have some DirContext objects we hold on to. So that whenever we
    need to access ldap, we dont have to re-instantiate InitialDirContext.

    Or at least that was teh idea.

    Now we find that if teh ldap is restarted *after* this DirContext
    object is instantiated, this object becomes unusable.
    ( Because the peer side of the original TCP socket it has been holding
    on to has been closed )
    Is there a way around it ?
    We are using the usual "com.sun.jndi.ldap.LdapCtxFactory"
    which supports along with other things connection pooling.

    1. Does it have something we can make use of ?
    2. Unrelated Q : When we tried the following code, it didnt give us the
    pooled connections.
    It gave the pooled connections only when all the connection pool
    parameters were given as system properties through the -D switch.
    Since we dont want to specify these properties for the whole system,
    is there a way to overcome this


    Hashtable env = new Hashtable(11);
    env.put(Context.INITIAL_CONTEXT_FACTORY,"");
    env.put(Context.PROVIDER_URL, "ldap://hostname:2389/dc=blah..");
    env.put(DirContext.SECURITY_PRINCIPAL, "uid=somebody,...");
    env.put(DirContext.SECURITY_CREDENTIALS, "passwd");
    env.put("com.sun.jndi.ldap.connect.pool", "true");
    env.put("com.sun.jndi.ldap.connect.pool.initsize", "3");
    env.put("com.sun.jndi.ldap.connect.pool.debug", "fine");
    DirContext ctx = new InitialDirContext(env);

    Thanks for reading


    --sony
     
    , Oct 18, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike S
    Replies:
    0
    Views:
    23,105
    Mike S
    Sep 16, 2004
  2. Mick
    Replies:
    2
    Views:
    9,669
    Marcin Grunwald
    Feb 23, 2005
  3. Stephan Koser

    How to reconnect to an LDAP Server

    Stephan Koser, Jul 20, 2005, in forum: Java
    Replies:
    0
    Views:
    1,596
    Stephan Koser
    Jul 20, 2005
  4. Bob Graton

    Auto reconnect to EJB

    Bob Graton, Nov 18, 2006, in forum: Java
    Replies:
    2
    Views:
    414
    Danno
    Nov 18, 2006
  5. linkswanted
    Replies:
    1
    Views:
    994
Loading...

Share This Page