-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JdbcAspect.getConnection
will execute SELECT USER()
every time
#173
Comments
Actually, I think it's hard for I resolved this issue by add this argument to mysql jdbc url:
After changing /**
* What's our user name as known to the database?
*
* @return our database user name
* @throws SQLException
*/
public String getUserName() throws SQLException {
if (this.conn.getUseHostsInPrivileges()) {
Statement stmt = null;
ResultSet rs = null;
try {
stmt = this.conn.getMetadataSafeStatement();
rs = stmt.executeQuery("SELECT USER()");
rs.next();
return rs.getString(1);
} finally {
if (rs != null) {
try {
rs.close();
} catch (Exception ex) {
AssertionFailedException.shouldNotHappen(ex);
}
rs = null;
}
if (stmt != null) {
try {
stmt.close();
} catch (Exception ex) {
AssertionFailedException.shouldNotHappen(ex);
}
stmt = null;
}
}
}
return this.conn.getUser();
} |
I think the userName is not necessary at all,because normally application accesses the database by a fixed user. And then we can replace the userName by database ip and port because this is helpful to draw topology. so the opentracing-jdbc project should support more info about database such as database ip and port In design level, I think opentracing-jdbc is not flexiable beacuse of it's construction method.So i suggest we need to improve the opentracing-jdbc firstly and then add database ip and port to acted as tag k-v. |
Now,TracingConnnection receieve a ConnectionInfo Object containing all the database information(instance,ip,port,type,username).So username is not required.And then we can reslove the database information by parse the jdbc url.For example the skywalking is doing so. |
@dozer47528 why close this issue,i think we need a pr to solve this problem |
@pavolloffay what do you think about my suggestion? |
@wuyupengwoaini would you like to contribute a fix with your solution? |
Ok, i'll try to fix it within a few days |
@pavolloffay please help me to review the pr |
I find the
getConnection()
method is slower than expected.So I check the source code:
For this line:
String user = conn.getMetaData().getUserName();
mysql-connector-java
will executeSELECT USER()
every time.The text was updated successfully, but these errors were encountered: