【发布时间】:2019-10-06 03:31:09
【问题描述】:
我创建了使用 jdbctemplate 的 spring-boot 应用程序,在 localhost 上一切正常,但是当我将应用程序部署到 Heroku 并访问端点时,我得到了以下信息:
StatementCallback; bad SQL grammar [SELECT id, name, price, image, description FROM products;]; nested exception is org.postgresql.util.PSQLException: ERROR: relation "products" does not exist Position: 49
如果 SQL 查询不好,那么同一个应用程序怎么可能在本地机器上运行?
这是我正在使用的 jdbcTemplate 方法:
public Products getProductsList() {
ArrayList<Product> productsList = new ArrayList<>();
jdbcTemplate.query(
"SELECT id, name, price, image, description FROM public.products;",
(rs, rowNum) -> new Product(rs.getInt("id"), rs.getString("name"), rs.getFloat("price"), rs.getString("image"), rs.getString("description"))
).forEach(product -> productsList.add(product));
return new Products(productsList);
}
【问题讨论】:
-
要么:1) 表“products”在部署的环境中不存在,2) 表名中有拼写错误(驼峰式、蛇式、小写、大写),或者如果这些是好,那么这个:stackoverflow.com/questions/36753568/…
-
就像我说的,它可以在本地机器上运行
标签: java spring-boot heroku jdbc jdbctemplate