Reputation: 604
I want to add a sniplet of code where I can print the connection id of the connection made to mysql using getConnection()
.
It is going to be used for monitoring the number of connections made at a time.
Upvotes: 0
Views: 1430
Reputation: 3400
Connection is an interface and is implemented by multiple database vendors. I am entirely sure whether you can get such a value, but it depends whether MySQL is actually allowing you to do or not.
Regarding you problem of monitoring the number of connections made at a time, based on your requirement you can actually go for a synchronized counter to maintain the number of times the connection made/closed/open. Hope that helps.
Upvotes: 1