标签:bug jdbc cto str ntp deb ram object close
JdbcTemplate的源码
注意QueryStatementCallback 是一个类。
public Object query(final String sql, final ResultSetExtractor rse) throws DataAccessException { if (sql == null) { throw new InvalidDataAccessApiUsageException("SQL must not be null"); } if (JdbcUtils.countParameterPlaceholders(sql, ‘?‘, "‘\"") > 0) { throw new InvalidDataAccessApiUsageException( "Cannot execute [" + sql + "] as a static query: it contains bind variables"); } if (logger.isDebugEnabled()) { logger.debug("Executing SQL query [" + sql + "]"); } class QueryStatementCallback implements StatementCallback, SqlProvider { public Object doInStatement(Statement stmt) throws SQLException { ResultSet rs = null; try { rs = stmt.executeQuery(sql); ResultSet rsToUse = rs; if (nativeJdbcExtractor != null) { rsToUse = nativeJdbcExtractor.getNativeResultSet(rs); } return rse.extractData(rsToUse); } finally { JdbcUtils.closeResultSet(rs); } } public String getSql() { return sql; } } return execute(new QueryStatementCallback()); }
标签:bug jdbc cto str ntp deb ram object close
原文地址:https://www.cnblogs.com/mkl34367803/p/14728947.html