diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java
index b3476192a5f98191b30da9d20667613edf3aea61..712934b392eb81fb6d3605789df236b7d0b1a043 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java
@@ -29,8 +29,11 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptR
import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
/**
- * {@link ConnectionServiceMethodInterceptor} create an exit span when the client call the following methods in the
- * class that extend {@link java.sql.Connection}. 1. close 2. rollback 3. releaseSavepoint 4. commit
+ * {@link ConnectionServiceMethodInterceptor} create an exit span when the following methods execute:
+ * 1. close
+ * 2. rollback
+ * 3. releaseSavepoint
+ * 4. commit
*
* @author zhangxin
*/
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/JDBC42PreparedStatementInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/JDBC42PreparedStatementInstrumentation.java
deleted file mode 100644
index 04f877fba86ca0b9de366c3e5aacb990eecaf7cc..0000000000000000000000000000000000000000
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/JDBC42PreparedStatementInstrumentation.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017, OpenSkywalking Organization All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Project repository: https://github.com/OpenSkywalking/skywalking
- */
-
-package org.skywalking.apm.plugin.jdbc.mysql.define;
-
-import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
-
-import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
-
-/**
- * {@link JDBC42PreparedStatementInstrumentation} intercepts {@link com.mysql.jdbc.JDBC42PreparedStatement} class.
- *
- * @author zhangxin
- */
-public class JDBC42PreparedStatementInstrumentation extends AbstractPreparedStatementInstrumentation {
- private static final String ENHANCE_CLASS = "com.mysql.jdbc.JDBC42PreparedStatement";
-
- @Override protected ClassMatch enhanceClass() {
- return byName(ENHANCE_CLASS);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/PreparedStatementInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/PreparedStatementInstrumentation.java
deleted file mode 100644
index bf0480f2d7c72d95fe514a6257b176e45a748da4..0000000000000000000000000000000000000000
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/PreparedStatementInstrumentation.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017, OpenSkywalking Organization All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Project repository: https://github.com/OpenSkywalking/skywalking
- */
-
-package org.skywalking.apm.plugin.jdbc.mysql.define;
-
-import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
-
-import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
-
-/**
- * {@link JDBC42PreparedStatementInstrumentation} intercepts {@link com.mysql.jdbc.PreparedStatement} class.
- *
- * @author zhangxin
- */
-public class PreparedStatementInstrumentation extends AbstractPreparedStatementInstrumentation {
-
- private static final String ENHANCE_CLASS = "com.mysql.jdbc.PreparedStatement";
-
- @Override protected ClassMatch enhanceClass() {
- return byMultiClassMath(ENHANCE_CLASS, "com.mysql.cj.jdbc.PreparedStatement");
- }
-
-}
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/resources/skywalking-plugin.def
deleted file mode 100644
index 622dc29d02608e7d0f98f06f58cd1007184c04ec..0000000000000000000000000000000000000000
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/resources/skywalking-plugin.def
+++ /dev/null
@@ -1,6 +0,0 @@
-mysql=org.skywalking.apm.plugin.jdbc.mysql.define.DriverInstrumentation
-mysql=org.skywalking.apm.plugin.jdbc.mysql.define.ConnectionInstrumentation
-mysql=org.skywalking.apm.plugin.jdbc.mysql.define.CallableInstrumentation
-mysql=org.skywalking.apm.plugin.jdbc.mysql.define.PreparedStatementInstrumentation
-mysql=org.skywalking.apm.plugin.jdbc.mysql.define.JDBC42PreparedStatementInstrumentation
-mysql=org.skywalking.apm.plugin.jdbc.mysql.define.StatementInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/pom.xml
similarity index 95%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/pom.xml
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/pom.xml
index efcbfa22fee0cd4fabbbedbc411dc8574f390bb7..eb232bb106c680f4521dea627511de5b246c1319 100755
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/pom.xml
@@ -25,10 +25,10 @@
4.0.0
- apm-mysql-2.x-plugin
+ apm-mysql-5.x-plugin
jar
- mysql-2.x-plugin
+ mysql-5.x-plugin
http://maven.apache.org
@@ -45,7 +45,7 @@
mysql
mysql-connector-java
- [2.0.14,6.0.6]
+ [5.1.22,6.0.6]
provided
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptor.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptor.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptor.java
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptor.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptor.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptor.java
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptor.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptor.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptor.java
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java
similarity index 88%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java
index d8fbd58cd96c8b8d543fc92b3f245072f2f59453..779ae38b0e468d3f768374b4a754772446ef808c 100644
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java
@@ -41,6 +41,13 @@ public class StatementExecuteMethodsInterceptor implements InstanceMethodsAround
MethodInterceptResult result) throws Throwable {
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
+ /**
+ * To protected the code occur NullPointException. because mysql execute system sql when constructor method in
+ * {@link com.mysql.jdbc.ConnectionImpl} class executed. but the interceptor set the connection Info after
+ * the constructor method executed.
+ *
+ * @see org.skywalking.apm.plugin.jdbc.JDBCDriverInterceptor#afterMethod(EnhancedInstance, Method, Object[], Class[], Object)
+ */
if (connectInfo != null) {
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/CallableInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/CallableInstrumentation.java
similarity index 91%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/CallableInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/CallableInstrumentation.java
index f0e2fbb6d4750b61fb1747ffe0283454401d8f9d..4d3152241c611ca35b64176225064f9ed2f3b8a4 100644
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/CallableInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/CallableInstrumentation.java
@@ -26,12 +26,14 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMet
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
-import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
+import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;
/**
* {@link CallableInstrumentation} define that the mysql-2.x plugin intercepts the following methods in the {@link
- * com.mysql.jdbc.CallableStatement} by {@link org.skywalking.apm.plugin.jdbc.mysql.CallableStatementInterceptor}. 1.
- * execute
2. executeQuery
3. executeUpdate
+ * com.mysql.jdbc.CallableStatement} by {@link org.skywalking.apm.plugin.jdbc.mysql.CallableStatementInterceptor}:
+ * 1. execute
+ * 2. executeQuery
+ * 3. executeUpdate
*
* @author zhangxin
*/
@@ -64,6 +66,6 @@ public class CallableInstrumentation extends ClassInstanceMethodsEnhancePluginDe
}
@Override protected ClassMatch enhanceClass() {
- return byMultiClassMath(ENHANCE_CLASS, "com.mysql.jdbc.cj.CallableStatement");
+ return byMultiClassMatch(ENHANCE_CLASS, "com.mysql.jdbc.cj.CallableStatement");
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
similarity index 97%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
index a45048cd1151d68546d88302190101c585bdc680..3ddded5bb85f8c4556d35508e7a354e3e20d5455 100644
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
@@ -35,7 +35,7 @@ import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_
import static org.skywalking.apm.plugin.jdbc.define.Constants.RELEASE_SAVE_POINT_METHOD_NAME;
import static org.skywalking.apm.plugin.jdbc.define.Constants.ROLLBACK_METHOD_NAME;
import static org.skywalking.apm.plugin.jdbc.define.Constants.SERVICE_METHOD_INTERCEPT_CLASS;
-import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
+import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;
/**
* {@link ConnectionInstrumentation} intercepts the following methods that the class which extend {@link
@@ -115,6 +115,6 @@ public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePlugin
}
@Override protected ClassMatch enhanceClass() {
- return byMultiClassMath(ENHANCE_CLASS, "com.mysql.cj.jdbc.ConnectionImpl");
+ return byMultiClassMatch(ENHANCE_CLASS, "com.mysql.cj.jdbc.ConnectionImpl");
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
similarity index 91%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
index 25d6ce62f2c163e348ef57c9185d0df060590516..d8d1a659cf302191506806f18c1c5b5ddf9f398f 100644
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
@@ -21,7 +21,7 @@ package org.skywalking.apm.plugin.jdbc.mysql.define;
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation;
-import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
+import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;
/**
* {@link DriverInstrumentation} presents that skywalking intercepts {@link com.mysql.jdbc.Driver}.
@@ -31,6 +31,6 @@ import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.by
public class DriverInstrumentation extends AbstractDriverInstrumentation {
@Override
protected ClassMatch enhanceClass() {
- return byMultiClassMath("com.mysql.jdbc.Driver", "com.mysql.cj.jdbc.Driver");
+ return byMultiClassMatch("com.mysql.jdbc.Driver", "com.mysql.cj.jdbc.Driver");
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/MultiClassNameMatch.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/MultiClassNameMatch.java
similarity index 94%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/MultiClassNameMatch.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/MultiClassNameMatch.java
index 839b3787584d0f986d58cfbb6abada7a010508b2..0dbb7eb4ae073976fd1bdadd95db884fe5f6f362 100644
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/MultiClassNameMatch.java
+++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/MultiClassNameMatch.java
@@ -28,7 +28,7 @@ import org.skywalking.apm.agent.core.plugin.match.IndirectMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
/**
- * Match multiple classes name with an explicit class name.
+ * Match class with a given set of classes.
*
* @author zhangxin
*/
@@ -61,7 +61,7 @@ public class MultiClassNameMatch implements IndirectMatch {
return matchClassNames.contains(typeDescription.getTypeName());
}
- public static ClassMatch byMultiClassMath(String... classNames) {
+ public static ClassMatch byMultiClassMatch(String... classNames) {
return new MultiClassNameMatch(classNames);
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/AbstractPreparedStatementInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/PreparedStatementInstrumentation.java
similarity index 70%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/AbstractPreparedStatementInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/PreparedStatementInstrumentation.java
index bf73036f9c89aae4e62ce2919bfda03d96bcc61b..ba83c888e1a0821c8a42d3cb966cd320173c5059 100644
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/AbstractPreparedStatementInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/PreparedStatementInstrumentation.java
@@ -23,12 +23,15 @@ import net.bytebuddy.matcher.ElementMatcher;
import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;
/**
- * {@link AbstractPreparedStatementInstrumentation} define that the mysql-2.x plugin intercepts the following methods in
- * the {@link com.mysql.jdbc.JDBC42PreparedStatement} and {@link com.mysql.jdbc.PreparedStatement} class.
+ * {@link PreparedStatementInstrumentation} define that the mysql-2.x plugin intercepts the following methods in the
+ * {@link com.mysql.jdbc.JDBC42PreparedStatement}, {@link com.mysql.jdbc.PreparedStatement} and {@link
+ * com.mysql.cj.jdbc.PreparedStatement} class:
* 1. execute
* 2. executeQuery
* 3. executeUpdate
@@ -37,9 +40,12 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
*
* @author zhangxin
*/
-public abstract class AbstractPreparedStatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+public class PreparedStatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+ private static final String PREPARED_STATEMENT_CLASS_NAME = "com.mysql.jdbc.PreparedStatement";
private static final String SERVICE_METHOD_INTERCEPTOR = "org.skywalking.apm.plugin.jdbc.mysql.StatementExecuteMethodsInterceptor";
+ public static final String MYSQL6_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.cj.jdbc.PreparedStatement";
+ public static final String JDBC42_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.jdbc.JDBC42PreparedStatement";
@Override protected final ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
@@ -66,4 +72,8 @@ public abstract class AbstractPreparedStatementInstrumentation extends ClassInst
}
};
}
+
+ @Override protected ClassMatch enhanceClass() {
+ return byMultiClassMatch(PREPARED_STATEMENT_CLASS_NAME, MYSQL6_PREPARED_STATEMENT_CLASS_NAME, JDBC42_PREPARED_STATEMENT_CLASS_NAME);
+ }
}
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementEnhanceInfos.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementEnhanceInfos.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementEnhanceInfos.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementEnhanceInfos.java
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementInstrumentation.java
similarity index 86%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementInstrumentation.java
index 0a63878ad600135e46f0a99f1d0342c634a53624..bd87bbc1440a89177285b405760242178daec388 100644
--- a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/StatementInstrumentation.java
@@ -26,11 +26,11 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMet
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
-import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
+import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;
/**
- * {@link JDBC42PreparedStatementInstrumentation} intercepts the following methods in the {@link
- * com.mysql.jdbc.JDBC42PreparedStatement} class.
+ * {@link StatementInstrumentation} intercepts the following methods in the {@link
+ * com.mysql.jdbc.StatementImpl} and {@link com.mysql.cj.jdbc.StatementImpl}class.
* 1. execute
* 2. executeQuery
* 3. executeUpdate
@@ -44,8 +44,9 @@ import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.by
* @author zhangxin
*/
public class StatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "com.mysql.jdbc.StatementImpl";
+ private static final String STATEMENT_CLASS_NAME = "com.mysql.jdbc.StatementImpl";
private static final String SERVICE_METHOD_INTERCEPTOR = "org.skywalking.apm.plugin.jdbc.mysql.StatementExecuteMethodsInterceptor";
+ public static final String MYSQL6_STATEMENT_CLASS_NAME = "com.mysql.cj.jdbc.StatementImpl";
@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
@@ -78,6 +79,6 @@ public class StatementInstrumentation extends ClassInstanceMethodsEnhancePluginD
}
@Override protected ClassMatch enhanceClass() {
- return byMultiClassMath(ENHANCE_CLASS, "com.mysql.cj.jdbc.StatementImpl");
+ return byMultiClassMatch(STATEMENT_CLASS_NAME, MYSQL6_STATEMENT_CLASS_NAME);
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000000000000000000000000000000000000..f4f6b4c6ebbd8c2f082dc0b98cb2802b3cf0d8ef
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,5 @@
+mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.DriverInstrumentation
+mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.ConnectionInstrumentation
+mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.CallableInstrumentation
+mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.PreparedStatementInstrumentation
+mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.StatementInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptorTest.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptorTest.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptorTest.java
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptorTest.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptorTest.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptorTest.java
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptorTest.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptorTest.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptorTest.java
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java
rename to apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java
diff --git a/apm-sniffer/apm-sdk-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/pom.xml
index 187cddb8fd6973f375b9ea0239940222845273c6..bae33b837858923f18575f08a60e981efea77fbe 100644
--- a/apm-sniffer/apm-sdk-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/pom.xml
@@ -48,7 +48,7 @@
sharding-jdbc-1.5.x-plugin
xmemcached-2.x-plugin
grpc-1.x-plugin
- mysql-2.x-plugin
+ mysql-5.x-plugin
h2-1.x-plugin
postgresql-8.x-plugin
oracle-10.x-plugin