B4J Question [SOLVED] HikariCP active connections

prajinpraveen

Active Member
Licensed User
Longtime User
Hi,

Is there a way to get active number of connections for HikariCP? HikariCP library

I have tried using javaobject. I am not great with Java and its implementations

Dim jo As JavaObject
jo.InitializeNewInstance("com.zaxxer.hikari.metrics.PoolStats",Null)

Error: Caused by: java.lang.NoSuchMethodException: com.zaxxer.hikari.metrics.PoolStats.<init>()

and

Dim jo As JavaObject
jo.InitializeStatic("com.zaxxer.hikari.metrics.PoolStats").RunMethod("getTotalConnections",Null)

Error: java.lang.IllegalArgumentException: object is not an instance of declaring class


Class: PoolStats.java

Thank you
 

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
This wrapper for HikariCP I wrote has some additional methods to check info on connections:


Note that it is better to use HikariCP-4.0.3 as it 5.x has some memory leak issues.

Alwaysbusy
 
Upvote 1

prajinpraveen

Active Member
Licensed User
Longtime User
B4X:
 public int getActiveConnections(){
      return connectionBag.getCount(STATE_IN_USE);
 }
is a Method in the HicariCP-Pool-Instance.

See https://github.com/brettwooldridge/...n/java/com/zaxxer/hikari/pool/HikariPool.java

I can not help to get it as i never used this Library. It´s just a note that there is such Method but i don´t know if the Library-Author implemented this Method.
Thanks @DonManfred

I bumped into this method. I wasn't successful to implement it. I will give it a try again. Thank you
 
Upvote 0

prajinpraveen

Active Member
Licensed User
Longtime User
This wrapper for HikariCP I wrote has some additional methods to check info on connections:


Note that it is better to use HikariCP-4.0.3 as it 5.x has some memory leak issues.

Alwaysbusy
I am going to try this. My app is written using ABMaterial Framework. Is 5.0.0 also problematic?
Thanks @alwaysbusy
 
Upvote 0

prajinpraveen

Active Member
Licensed User
Longtime User
Yes. We've noticed problems with 5.x in our ABM apps this summer. We've downgraded to 4.0.3 last week and are keeping an eye on it if it is better.
Tried ABHikari. works like a charm. Been using ABMaterial+c3p0 for a production App for years. At times i see that the open connection using c3p0 just goes up. No warning, No errors. The same code can run for days and weeks without increase in active connections. Wonder why.

Thought of switching to HikariCP and give it a try.
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
B4X:
 public int getActiveConnections(){
      return connectionBag.getCount(STATE_IN_USE);
 }
is a Method in the HicariCP-Pool-Instance.

See https://github.com/brettwooldridge/...n/java/com/zaxxer/hikari/pool/HikariPool.java

I can not help to get it as i never used this Library. It´s just a note that there is such Method but i don´t know if the Library-Author implemented this Method.
I can add this to the library if it works. When I looked there was only a private method to get the count. This was shown in the test sources only so I didn’t add it to the library as it relied on changing the access from private to public.
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
I'm using HikariCP v5.0.1 in production with over 10M queries per day, without any problems in last two months.
When there is a continuous connection via Hicari it will not disconnect. Leave for 1-2 days without connection and it will be discarded. With such a number of connections, you cannot be kicked out. I was also using Hicari (the project died already) for over 2 years with a few thousand online users and it worked much better than mysql itself.
 
Upvote 0

prajinpraveen

Active Member
Licensed User
Longtime User
I can add this to the library if it works. When I looked there was only a private method to get the count. This was shown in the test sources only so I didn’t add it to the library as it relied on changing the access from private to public.
thanks. there is a method "poolstats" that shows all the indicators
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
I have added the following methods.

B4X:
    Log(cp.ActiveConnections)
    Log(cp.IdleConnections)
    Log(cp.ThreadsAwaitingConnection)
    Log(cp.TotalConnections)

Code and binaries are on github (see original post)

 
Upvote 1

prajinpraveen

Active Member
Licensed User
Longtime User
I have added the following methods.

B4X:
    Log(cp.ActiveConnections)
    Log(cp.IdleConnections)
    Log(cp.ThreadsAwaitingConnection)
    Log(cp.TotalConnections)

Code and binaries are on github (see original post)

Please will you reupload HikariCP/HikariCP_5.01 (ope ltd).zip
Seems to be corrupt
 
Upvote 0
Top