sylvainlaurent / JDBC-Performance-Logger

A JDBC driver wrapper and GUI to analyze statement performance
Apache License 2.0
84 stars 26 forks source link

Use java Attach API to avoid jvm restart and javaagent parameter #54

Open eostermueller opened 8 years ago

eostermueller commented 8 years ago

Hello,

Was thinking that the com.sun.tools.attach api would make it easier for people to install/adopt this tool.

Curious if you have tried it and ran into issues or just haven't had the time?

Thanks, --Erik Ostermueller

sylvainlaurent commented 8 years ago

hello,

I thought about it but did not try as it appeared to require more work... But feel free to create a pull request!

eostermueller commented 7 years ago

Greetings,

I'm in the middle of trying to code support for this issue I created. Loading the agent jar file without the javaagent parameter was pretty straight forward. I have this coded on my own local fork. But I've run into a problem I don't know how to deal with.

The code at link [1] below suggests that ByteBuddy leaps into action when a java.sql.Driver is instantiated. Unfortunately, the goal of my enhancement is to launch the agent minutes or even hours/days after the jdbc Driver has already been instantiated.

Perhaps my enhancement could iterate thru DriverManager.getDrivers() (see link [2]) and pass the instances on to ByteBuddy? If that looks helpful, perhaps you could show me what that code would look like?

Thanks, --Erik

[1] https://github.com/sylvainlaurent/JDBC-Performance-Logger/blob/master/jdbc-perf-logger-agent/src/main/java/ch/sla/jdbcperflogger/agent/Agent.java#L46

[2] https://docs.oracle.com/javase/8/docs/api/java/sql/DriverManager.html#getDrivers--

sylvainlaurent commented 6 years ago

I'm not at all a ByteBuddy expert. You should try to get some help with the ByteBuddy community.