. First , the SQL statement:
I checked the decompiled source code of JdbcTemplate and found that the log level of the print statement is debug.
Therefore, add the log4j parameter: log4j. logger.org.springframework.jdbc.core.JdbcTemplate=debug
public int update(String sql) throws DataAccessException { Assert.notNull(sql, "SQL must not be null"); if (this.logger.isDebugEnabled()) { this.logger.debug("Executing SQL update [" + sql + "]"); }
Followed by statement parameters:
also track the execution process of praparedStatement, add parameters: log4j.logger.org.springframework.jdbc.core.StatementCreatorUtils=debug
Final effect:
17:05:26,034 DEBUG JdbcTemplate:574 - Executing prepared SQL statement [select * from A WHERE ID=?]
17:05:26,459 DEBUG StatementCreatorUtils:207 - Setting SQL statement parameter value: column index 1, parameter value [1111], value class [java.lang.String], SQL type 12