java - spring jdbc 模板返回空结果

标签 java spring jdbctemplate

我有以下代码

resultList = daoResources.jdbcTemplate.query(sql, selectParams, new BeanPropertyRowMapper(resultClass));

当针对数据库使用 selectParams 运行 SQL 时,我得到结果。 sql的选择字段名称也与resultClass中的字段匹配。但对于上面的代码,我得到一个空的 resultList。

问题可能出在哪里?

最佳答案

在这种情况下,调试是你的 friend 。我建议您启用 jdbc 模板的调试日志,以查看发送到数据库的 sql 和绑定(bind)参数。以下来自3.0.x reference doc

All SQL issued by this class is logged at the DEBUG level under the category corresponding to the fully qualified class name of the template instance (typically JdbcTemplate, but it may be different if you are using a custom subclass of the JdbcTemplate class).

关于java - spring jdbc 模板返回空结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8515358/

相关文章:

java - 使用 JdbcTemplate 在 Spring Boot 中耗尽连接池

java - 如何使用java lambda表达式实现RowMapper

java - Spring 4.x 与 Spring Integration 4.X ClassLoader 问题

java - 通过将其导出为 jar 文件,在不同的项目中重用我的 java 代码

Spring cloud 为不同的配置文件配置本地和远程存储库

java - jdbcTemplate.update(String sql) 行为异常

java - 为什么我在 collect() 之后调用 stream() 时得到 Stream<Object>?

java - 使用 Spring Boot Maven 插件作为构建器,Runnable Jar (JavaFx) 无法找到 log4j2.xml

java - 将随机数转换为一组数组

java - BufferedInputStream 和 BufferedOutputstream 与 InputStream 和 Outputstream 有区别吗