>>>>>
mysql version 8.0 以上
package cn
.zhangfusheng
.base
.server
.core
.datasource
.log
;
import lombok
.extern
.slf4j
.Slf4j
;
import com
.mysql
.cj
.MysqlConnection
;
import com
.mysql
.cj
.Query
;
import com
.mysql
.cj
.interceptors
.QueryInterceptor
;
import com
.mysql
.cj
.log
.Log
;
import com
.mysql
.cj
.protocol
.Resultset
;
import com
.mysql
.cj
.protocol
.ServerSession
;
import java
.util
.Properties
;
import java
.util
.function
.Supplier
;
@Slf4j
public class AbstractQueryInterceptor implements QueryInterceptor {
@Override
public QueryInterceptor
init(MysqlConnection conn
, Properties props
, Log log
) {
return this;
}
@Override
public <T
extends Resultset> T
preProcess(Supplier
<String> sql
, Query interceptedQuery
) {
return null
;
}
@Override
public boolean executeTopLevelOnly() {
return false;
}
@Override
public void destroy() {
}
@Override
public <T
extends Resultset> T
postProcess(Supplier
<String> sql
, Query interceptedQuery
, T originalResultSet
, ServerSession serverSession
) {
if (interceptedQuery
!= null
) {
log
.debug("\n\turl: {}\n\tsql: {}", interceptedQuery
.getSession().getHostInfo().getDatabaseUrl(), sql
);
}
return originalResultSet
;
}
}
转载请注明原文地址: https://lol.8miu.com/read-21172.html