Conversation
| System.out.println("finally interceptor"); | ||
| } | ||
| return reVal; | ||
| } |
There was a problem hiding this comment.
Sample 我们补充一个 https://www.sqlite.org/index.html sqllite 或者 http://www.h2database.com/html/main.html H2DB 的实例吧,这样场景更完整些
There was a problem hiding this comment.
if (initialized) {
return;
}
realPreparedStatement = doPrepareStatement(sql);
for (PreparedParameter preparedParameter : preparedParameters) {
preparedParameter.invoke(realPreparedStatement);
}
initialized = true;
- 这里在并发时,会有重复初始化的风险
There was a problem hiding this comment.
@QilongZhang 这里多个线程同时调用这个实例方法就会有并发初始化的问题。 @Xiaoshu-Yan 关注哈。
| <groupId>com.alipay.sofa</groupId> | ||
| <artifactId>tracer-sofa-boot-starter</artifactId> | ||
| </dependency> | ||
| ``` |
| 该样例工程使用 H2 内存数据库,并暴露 /create 用于新建一张数据表,用户访问 /create 即可执行创建数据库表 SQL 语句: | ||
| ```sql | ||
| DROP TABLE IF EXISTS TEST; | ||
| CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255)); |
There was a problem hiding this comment.
这个仅仅是为了演示该条sql语句的tracer记录
|
@QilongZhang 和同步之前的代码冲突了。 |
There was a problem hiding this comment.
@QilongZhang 这里多个线程同时调用这个实例方法就会有并发初始化的问题。 @Xiaoshu-Yan 关注哈。
There was a problem hiding this comment.
Already import SofaTracerConfiguration , No need import static field of this.
There was a problem hiding this comment.
@ujjboy it need. I try to delete it , but compile error.
There was a problem hiding this comment.
TRACER_APPNAME_KEY change to SofaTracerConfiguration.TRACER_APPNAME_KEY
There was a problem hiding this comment.
change to org.junit.Assert#assertTrue()
There was a problem hiding this comment.
change to org.junit.Assert#assertTrue()
There was a problem hiding this comment.
change to org.junit.Assert#assertTrue()
| createDataSourceProxy(beanFactory, beanName, dataSource, getTomcatJdbcUrlKey()); | ||
| } else if (DataSourceUtils.isHikariDataSource(dataSource.getBeanClassName())) { | ||
| createDataSourceProxy(beanFactory, beanName, dataSource, getHikariJdbcUrlKey()); | ||
| } |
There was a problem hiding this comment.
It seems getXXKey() can move to DataSourceUtils, too. The code will more simple, like
createDataSourceProxy(beanFactory, beanName, dataSource, getJdbcUrlKeyByDataSource());
There was a problem hiding this comment.
it has been moved to DataSourceUtils.
| * @author qilong.zql | ||
| * @since 2.2.0 | ||
| */ | ||
| public abstract class BasePreparedStatement implements PreparedStatement { |
There was a problem hiding this comment.
@Xiaoshu-Yan 保留? 主站会使用sql服务端埋点,可以直接依赖开源版扩展。
There was a problem hiding this comment.
这个类名去掉Abstract改成 PreparedStatementInterceptorChainImpl
There was a problem hiding this comment.
这个类名也改一下吧 StatementInterceptorChainImpl
| } | ||
|
|
||
| public static String resolveDatabaseFromUrl(String url) { | ||
| Assert.isTrue(!StringUtils.isBlank(url), "Jdbc url must not be empty!"); |
There was a problem hiding this comment.
考虑一下其他类型数据库,比如
oracle(jdbc:oracle:thin:@localhost:1521:sid)
sqlserver(jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks)
There was a problem hiding this comment.
@Xiaoshu-Yan 已修改,1、支持 SQLServer 2、支持 oracle SID 格式
|
@QilongZhang 修改一下前面review |
#53