Check LDAP connection (Java)

I'm using javax naming to connect to an LDAP database. Is there a good way to check if a connection is still valid? I'm looking for something really efficient here because it may need to be done often.

After some web searching all I have found is a suggestion to do a quick search, is there any more lightweight way?


Asked by: Aida483 | Posted: 21-01-2022

Answer 1

Is there a reason you can't just assume it is still valid? That seems the most efficient. Encapsulate the LDAP communication in a class. You can handle any exceptions due to a dropped connection by reconnecting and then re-performing the requested operation.

Answered by: Freddie151 | Posted: 22-02-2022

Similar questions

sockets - java connection to jabber

What type of stream I need to use to write a connect request message over a tcp socket, to jabber. I'mwriting a string with xml format. It should worked with the default socket stream or a dataoutputstream but it doesn't.

java - Connection to Oracle without a username or password

Oracle has this concept of allowing database users to be identified by the operating system user who is running the program that is connecting to Oracle. See here. This allows you to do, as that user on a unix machine for example, a command such as: sqlplus / I am attempting to write a Java...

java - How to determine database type for a given JDBC connection?

I need to handle resultsets returning stored procedures/functions for three databases (Oracle, sybase, MS-Server). The procedures/functions are generally the same but the call is a little different in Oracle. statement.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR); ... statement.execute(); ResultSet rs = (ResultSet)statement.getObject(1); JDBC doesn't provide a generic way to ha...

spring - How can I set up an LDAP connection pool in a Java EE Container?

I need to put an LDAP contextSource into my Java EE container's JNDI tree so it can be used by applications inside the container. I'm using Spring-LDAP to perform queries against ORACLE OVD. For development, I simply set up the contextSource in the Spring xml configuration file. For production, however, I need to be able to use a JNDI lookup to grab the connection/context from the container (as suggested here:

Java connection to / between Microsoft Windows Office Suite?

I read elsewhere (a response by "hazzen" here) that .NET has "a binding for the entire Office suite outlined here that allows you to write COM-based methods that you can call from Office. It is intended for automation, but you can write any managed code you want and have Excel call into it." I'...

java - Android HTTP Connection

Can anybody tell my why this doesn't work in the Android emulator? From the browser I have access and the server is internal. All I can think of is that I'm missing some configuration on my app so it can access the network layer. try { InetAddress server = Inet4Address.getByName("thehost"); //Doesn't work either //or InetAddress server2 = Inet4Address.getByAddress(new String("").getB...

java - How to create an SSL connection using the Smack XMPP library?

I'm building a small program that acts as an XMPP client and I am using the Smack library. Now, the server I am connecting to requires SSL (in Pidgin I have to check "Force old (port 5223) SSL"). I'm having trouble getting Smack to connect to this server. Is it possible?

java - HTTP Connection Pooling in GlassFish

In my webservice, I need to place some HTTP calls. Is it possible to do some connection pooling, like I do JDBC connection pooling? In the Admin Console of GlassFish I see the configuration items Connector Connection Pool and Connector Resources. Can I use these?

java - Proxool maximum connection count

I'm using proxool java connection pool (version 0.9.1). Everything works fine till I reach the maximum connection count. If the maximum connection count is reached proxool immediately throws an SQLExcepion: java.sql.SQLException: Couldn't get connection because we are at maximum connection count (n/n) and there are none av...

java - How can multiple webapps in the same tomcat instance share database connection pool?

Having in mind that each webapp has its own separate database (but all databases are in the same database server). The scenario is that I have a multi-tenant saas application - I deploy the same application for each customer. Each customer works on a database that is called db_cid, where cid is the customer id, i.e. a a unique customer identifier. Working with hibernate.

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)