Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to know Information of a Connection Pool

37 views
Skip to first unread message

Venkat Raghava Moganti

unread,
Feb 20, 2002, 9:08:04 AM2/20/02
to

HI,

I want to know the information of a connection pool for example its maxSize and
what are the active connections in the pool programitically ie. thr' code.
I can monitor them thr' console.But how to monitor a pool thr' code.

And what does all the attributes like WaitSecondsHigh,Waiters,
WaitersHigh mean.how can i get information about them.
And how do i get the information of them thr' code.

I have seen that JDBCConnectionPoolRuntime gives information about the pool.But
how to create a object of this interface.
Can anyone provide me the code for this.

Let me explain more....
I have created a demo pool and has set the maximum connections size as 2.I tried
to get 3 connections from the pool and obvious a exception has raised.(java.sql.SQLException:
Pool connect failed: weblogic.common.ResourceException: None available).

so i am writing a class such that it keeps the connections in wait state when
the pool has reached its maximum value for which i should know what are the active
connections and the maximum size of the pool.

So please if any one can help me how to know these values of the connetion pool
programitically,it would be great.

Eric Velazquez

unread,
Feb 20, 2002, 11:29:59 AM2/20/02
to
Ventak:
This is a sample code i wrote some time ago.

import weblogic.management.MBeanHome;
import weblogic.management.WebLogicMBean;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.AuthenticationException;
import javax.naming.CommunicationException;
import weblogic.jndi.Environment;

import java.util.Collection;
import java.util.Iterator;
import weblogic.management.runtime.JDBCConnectionPoolRuntimeMBean;
import weblogic.management.configuration.JDBCConnectionPoolMBean;
import weblogic.management.WebLogicObjectName;

public class mbean
{
public static void main(String args[])
{
MBeanHome home = null;
try
{
Environment env = new Environment();

env.setProviderUrl(url);
env.setSecurityPrincipal(username);
env.setSecurityCredentials(password);
Context ctx = env.getInitialContext();

home = (MBeanHome) ctx.lookup(MBeanHome.JNDI_NAME+".wlcsServer");

// Note the type of the Mbean: JDBCConnectionPoolConfig - The fixed
configuration of the pool just as the console
// JDBCConnectionPoolRuntime - The runtime parameters of the pool, like
current connections

// To retrieve the Mbean JDBCConnectionPoolMBean via ObjectName
WebLogicObjectName o = new
WebLogicObjectName("commercePool","JDBCConnectionPoolConfig","wlcsDomain","w
lcsServer");
JDBCConnectionPoolMBean pool = (JDBCConnectionPoolMBean)home.getMBean(o);

// the same Mbean but without ObjectName
JDBCConnectionPoolMBean pool =
(JDBCConnectionPoolMBean)home.getMBean("ccPoolSuc","JDBCConnectionPoolConfig
");
System.out.println("TableName " + pool.getTestTableName());


// To retrieve the JDBCConnectionPoolRuntimeMBean
JDBCConnectionPoolRuntimeMBean poolR =
(JDBCConnectionPoolRuntimeMBean)home.getMBean(new
WebLogicObjectName("wlcsDomain:ServerRuntime=wlcsServer,Name=sucPool,Locatio
n=wlcsServer,Type=JDBCConnectionPoolRuntime"));
System.out.println("getActiveConnectionsCurrentCount()" +
poolR.getActiveConnectionsCurrentCount());

// To retrieve a collection of the Mbeans by Type
Collection Beans = home.getMBeansByType("JDBCConnectionPoolRuntime");


}
catch(Exception ex)
{
System.out.println("Error " + ex);
ex.printStackTrace();
}
return;

}
}


These are extracts of the actual code, providing you diferent ways.

By the way, the issue you are trying to solve with a waiting time for a
connection to be available is an out-of-the-box functionality of the
weblogic pool. But is also restricted to some like 5 secs. (if i remember
well) and the reason is to avoid thread contention.
So if you are going to implement some like that must be much carefull. The
better way is to play with the InitialCapacity, MaxCapacity,
CapacityIncrement and ShrinkPeriod parameters, giving the enough connections
to avoid as possible as you can the situation in which exists waiters of
connections.

Hope this help.


"Venkat Raghava Moganti" <Venkat....@orbitech.co.in> wrote in message
news:3c73adc4$1...@newsgroups.bea.com...

0 new messages