mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-09 09:24:03 +08:00
优化数据源日志提示
This commit is contained in:
@@ -16,14 +16,19 @@ import java.util.Objects;
|
||||
*/
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
public class DefaultJdbcExecutor extends AbstractJdbcSqlExecutor {
|
||||
|
||||
|
||||
protected String getDatasourceId() {
|
||||
String id = DataSourceHolder.switcher().currentDataSourceId();
|
||||
return id == null ? "default" : id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() {
|
||||
DataSource dataSource = DataSourceHolder.currentDataSource().getNative();
|
||||
Connection connection = DataSourceUtils.getConnection(dataSource);
|
||||
boolean isConnectionTransactional = DataSourceUtils.isConnectionTransactional(connection, dataSource);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("DataSource ({}) JDBC Connection [{}] will {}be managed by Spring", DataSourceHolder.switcher().currentDataSourceId(), connection, (isConnectionTransactional ? "" : "not "));
|
||||
logger.debug("DataSource ({}) JDBC Connection [{}] will {}be managed by Spring", getDatasourceId(), connection, (isConnectionTransactional ? "" : "not "));
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
@@ -31,7 +36,7 @@ public class DefaultJdbcExecutor extends AbstractJdbcSqlExecutor {
|
||||
@Override
|
||||
public void releaseConnection(Connection connection) throws SQLException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Releasing DataSource ({}) JDBC Connection [{}]", DataSourceHolder.switcher().currentDataSourceId(), connection);
|
||||
logger.debug("Releasing DataSource ({}) JDBC Connection [{}]", getDatasourceId(), connection);
|
||||
}
|
||||
DataSourceUtils.releaseConnection(connection, DataSourceHolder.currentDataSource().getNative());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user