Thursday, May 27, 2010

Testing LDAP CONCURRENT CONNECTION

This Sample Java code allows to Test the connectivity to OID server in a loop(for concurrent number of times.)
This code used getDefaultDirCtx() Method of ConnectionUtil Inteface to get connection to OID
//The code Start Here
import javax.naming.NamingException;
import oracle.ldap.util.jndi.ConnectionUtil;
import oracle.ldap.util.CommunicationErrorException;
public class testLDAP {public testLDAP() throws NamingException {
String ldapUser = "cn=orcladmin";
String ldapPwd = ;
String ldapHost = ;
//String ldapPortSSL ="13130" ;
String ldapPort ="389" ;
try{ for(int i=0;i<20;i++)
{System.out.println("--------Trying to connect to the OID server connection Number--------" +i + "\n");
ConnectionUtil.getDefaultDirCtx(ldapHost, ldapPort, ldapUser, ldapPwd, 1000);
System.out.println("Connected successfully to " +ldapHost + " on the Non-SSL port : "+ ldapPort+"\n" );
//ConnectionUtil.getDefaultDirCtx(host, port, bindDN, bindPwd, timelimit) }
}catch(Exception e)
{System.out.println (e);}
}
public static void main(String[] args) throwsNamingException { testLDAP class1 = new testLDAP();class1.getClass();}}
//The code END Here

No comments:

Post a Comment