Hello Jerry,

To be tested, but perhaps connectionProperties can help you on this? [1]

Hope it helps,

Luis

[1] https://tomcat.apache.org/tomcat-9.0-doc/jdbc-pool.html

El jue., 5 dic. 2019 a las 19:42, Jerry Malcolm (<techst...@malcolms.com>)
escribió:

> I'm trying to add some code to monitor my jdbc data connection pool.
> Each time a connection is requested, I have some jmx code that logs
> values from the datasource mbean.  I haven't done much jmx coding.  So
> consider me a rookie on this topic.  I found some code on the web that
> does pretty much what I need. The relevant part of the code:
>
>            MBeanServer server = ManagementFactory.getPlatformMBeanServer();
>            Set<ObjectName> objectNames = server.queryNames(null, null);
>            for (ObjectName name : objectNames) {
>                MBeanInfo info = server.getMBeanInfo(name);
>                if (info.getClassName().equals(
> "org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool"))  {
>                    for (MBeanAttributeInfo mf : info.getAttributes()) {
>
> This code works.  The problem is that I have a bunch of virtual hosts
> running on the same instance of TC.  So I get a bunch of matching
> mbeans, apparently one for each virtual host / resource defined.
>
> Is there any way to identify which mbean is for the datasource I
> currently care about?  I was hoping there would be an attribute with the
> datasource name or the database name or even just some way to add a
> unique identifier when I create it.  But I don't see anything.  I've
> resorted to having maxTotal set to incrementally different values in all
> of my resource statements just so I can identify the datasource I'm
> looking at in the logs.  But that's a hack.
>
> Is there a better way to uniquely identify datasource mbeans in jmx?
>
> Thx
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

-- 

"Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."

- Samuel Beckett

Reply via email to