How do I enumerate/count all open JDBC connections? I've seen this thread, which doesn't answer my question.
My interest is in writing test code in which the object being tested (call it ConnectionUser) maintains its own connection. In my tests, I want to do things like verify that instantiating ConnectionUser doesn't open a connection, and that calling ConnectionUser.open results in one open connections. I'm not interested in enumerating/counting connections in the production code itself or implementing a connection pool.
I've thought about using something like jmockit to verify invocations of the static DriverManager.getConnection method, but would prefer something less abstract - i.e, have the driver just give me a list of all open connections.