Jdbctemplate query for string: EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0

前端 未结 17 1223
执笔经年
执笔经年 2020-11-29 16:22

I am using Jdbctemplate to retrieve a single String value from the db. Here is my method.

    public String test() {
        String cert=null;
        Strin         


        
17条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 16:57

    In Postgres, you can make almost any single value query return a value or null by wrapping it:

    SELECT (SELECT ) AS value
    

    and hence avoid complexity in the caller.

提交回复
热议问题