This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Security and the fly likes LDAP connection  close Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "LDAP connection  close" Watch "LDAP connection  close" New topic

LDAP connection close

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
How shall i close the LDAP connection ? i am using Netscape Directory server.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
I guess closing the ldap initial context s'd suffice.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
Any update ?
sherjeelmd ghouse

Joined: Nov 17, 2005
Posts: 7
Call the close on DirContext.

Here is the code. Connection pooling might be helpful for you.

Hashtable env = new Hashtable(11);
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");

// Enable connection pooling
env.put("com.sun.jndi.ldap.connect.pool", "true");

// Create one initial context (Get connection from pool)
DirContext ctx = new InitialDirContext(env);

// do something useful with ctx

// Close the context when we're done
ctx.close(); // Return connection to pool

I agree. Here's the link:
subject: LDAP connection close
Similar Threads
wli7.0sp1 startup problem.. another one
H2 database consule lockings
Connection Leaks
Ldap problem
consuquences of not closing ResultSet?