我使用 Jdbctemplate 从 db 中检索一个 String 值。
public String test() {
String cert=null;
String sql = "select ID_NMB_SRZ from codb_owner.TR_LTM_SLS_RTN
where id_str_rt = '999' and ID_NMB_SRZ = '60230009999999'";
cert = (String) jdbc.queryForObject(sql, String.class);
return cert;
}
在我的场景中,完全有可能没有得到我的查询命中,所以我的问题是如何绕过以下错误消息。
EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
It would seem to me that I should just get back a null instead of throwing an exception. How can I fix this? Thanks in advance.