when i use connection pool
i run this function search(LDAPUrl toGet),it will appear a error :can not close the connection
so i try to correct the bug,it is no problem:
LDAPConfigurationReader LDAPConfigurationReader = null;
LDAPConfigurationReader=LDAPConfigurationReader.getInstance();
Map hashMap = null;
try {
hashMap = LDAPConfigurationReader.getConfiguration();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
connectionFactory=ConnectionFactory.getInstance
();
poolManager=connectionFactory.connection(hashMap);
LDAPConnection=connectionFactory.bindConnection(poolManager);
LDAPSearchResults searchResults = LDAPConnection.search
(LDAPConnection,myUrl );
public static LDAPSearchResults search(LDAPConnection LDAPConnection,LDAPUrl toGet)
throws LDAPException
{
// Get a clone of default search constraints, method alters batchSize
return search( LDAPConnection,toGet, null);
}
public static LDAPSearchResults search(LDAPConnection LDAPConnection,LDAPUrl toGet,
LDAPSearchConstraints cons)
throws LDAPException
{
if( Debug.LDAP_DEBUG) {
Debug.trace( Debug.apiRequests,
"LDAPConnection.search(" + toGet.toString() + ")");
}
//LDAPConnection lconn = new LDAPConnection();
LDAPConnection.connect(toGet.getHost(),toGet.getPort());
if( cons == null) {
// This is a clone, so we already have our own copy
cons = LDAPConnection.getSearchConstraints();
} else {
// get our own copy of user's constraints because we modify it
cons = (LDAPSearchConstraints)cons.clone();
}
cons.setBatchSize(0); // Must wait until all results arrive
LDAPSearchResults toReturn = LDAPConnection.search(toGet.getDN(),
toGet.getScope(), toGet.getFilter(), toGet.getAttributeArray
(),
false, cons);
//lconn.disconnect();
return toReturn;
}
--
My MSN:zhoujianguo_leo@hotmail.com
i from china shanghai