1 看源码
-
org.springframework.jdbc.core包下面的所有类,输出debug级别的日志
-
org.springframework.jdbc.core.JdbcTemplate 类,输出debug级别的日志
-
org.springframework.jdbc.core.StatementCreatorUtils类,输出trace级别的日志
直接看源码
/org/springframework/jdbc/core/JdbcTemplate.class
public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
// 略
@Nullable
public <T> T execute(PreparedStatementCreator psc, PreparedStatementCallback<T> action) throws DataAccessException {
Assert.notNull(psc, "PreparedStatementCreator must not be null");
Assert.notNull(action, "Callback object must not be null");
if (this.logger.isDebugEnabled()) {
String sql = getSql(psc);
// 可以看到,debug 级别的sql
this.logger.debug("Executing prepared SQL statement" + (sql != null ? " [" + sql + "]" : ""));
}
// 略
}
// 略
}
/org/springframework/jdbc/core/StatementCreatorUtils.class
public abstract class StatementCreatorUtils {
// 略
// 设置 通配符 ? 的值
private static void setParameterValueInternal(PreparedStatement ps, in