JNDI Connection Pool issue

nathaniel_auvil_at_yahoo.com
Date: 01/31/05


Date: 31 Jan 2005 07:17:31 -0800

I have found something strange with the jdk jndi connection pool. The
pool will lock if you do not iterate all the data returned from a
query. I attached code i was using to test.

If you do not iterate over all the results returned by the query, the
pool will lock until the timeout is reached. Try commenting out the
SearchResults and running.

public class JDKConnectionPool implements Runnable
{
private static HashMap connections;

private static long sleepMillis= 1000;
private static int numThreads= 25;
private static int activeThreads= numThreads;
private int numQueries= 3;

/************************************************************************************************
*
* @param args[]

***********************************************************************************************/
public static void main( String[] args )
{
System.setProperty( "com.sun.jndi.ldap.connect.pool.debug", "all" );
System.setProperty( "com.sun.jndi.ldap.connect.pool.maxsize", "3" );
System.setProperty( "com.sun.jndi.ldap.connect.pool.initsize", "3" );
System.setProperty( "com.sun.jndi.ldap.connect.pool.prefsize", "3" );
System.setProperty( "com.sun.jndi.ldap.connect.pool.timeout", "30000"
);

connections= new HashMap();

for( int i= 0; i < numThreads; i++ )
{
JDKConnectionPool poolTester= new JDKConnectionPool();
Thread thread= new Thread( poolTester, "" + i );
thread.start();
}
}

/************************************************************************************************
*

***********************************************************************************************/
public void run()
{
Hashtable ht= new Hashtable();
ht.put( Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory" );
ht.put( "com.sun.jndi.ldap.connect.pool", "true" );
ht.put( Context.PROVIDER_URL,
"ldap://myldap.mycompany.com:389/o=theRoot" );

InitialDirContext ctx= null;

while( this.numQueries > 0 )
{
try
{
ctx= new InitialDirContext( ht );
Attributes matchAttributes= new BasicAttributes();

//displayResults( ctx.search( "ou=somePeople", matchAttributes ) );

NamingEnumeration namingEnumeration= ctx.search( "ou=somePeople",
matchAttributes );
while( namingEnumeration.hasMoreElements() )
{

SearchResult searchResult= (SearchResult)
namingEnumeration.next();
//System.out.println( "found: " + searchResult.getName() );
break;
}
}
catch( Exception e )
{
e.printStackTrace();
}
finally
{
try
{
if( ctx != null )
{
ctx.close();
Thread.yield();
}
}
catch( Exception e )
{
e.printStackTrace();
}
}

this.numQueries--;
}

activeThreads--;
System.out.println( "----Thread: " + Thread.currentThread().getName()
+ " is done!!!!!!!" );

        }



Relevant Pages

  • Re: gdb help: debugging a segfault in boost::shared_ptr
    ... I am developing a database connectivity plugin for the Remedy Action ... I've developed a database pool for the plugin so the time ... The pool will also check if the connections are ... Thread-safe means that shared_ptr handle ...
    (comp.os.linux.development.apps)
  • Re: determining max pool size
    ... the larger the pool size, the more requests can be server. ... 500 open connections to SQL server I awfully lot.... ... close the connection without even executing the sql statement). ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: MaxPoolSize - Recommendations
    ... Perhaps the pool is not leaking, ... using connections efficiently. ... for average 80 concurrent users. ... Microsoft doesn't have any recommendations concerning "max pool size" ...
    (microsoft.public.dotnet.framework.adonet)
  • Troubleshooting Timeout expired. All pooled connections were in use and max pool size was reached.
    ... use and max pool size was reached. ... connections were in use and max pool size was reached. ... I did not see any significant activity on the webserver. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: meaning of max pool size ?
    ... Max Pool Size determines how many connections will be kept open (once ... If a connection string is different than any existing ... where distinct connection strings means ...
    (microsoft.public.dotnet.framework.adonet)