Source code: service implementation class:
String select_sql = "select cguid,(case isrz when 1 then 'PASS' when 0 then 'FAIL' end) as smrzzt from t_jb_user where mobile=?"; List<Map<String,Object>> list = ydbsDaoI.findList(select_sql, new Object[]{phoneno});//Take out the result of the query String cguid = list.get(0).get("cguid")==null?"":list.get(0).get("cguid").toString(); String smrzzt = list.get(0).get("smrzzt")==null?"":list.get(0).get("smrzzt").toString();
An error is reported because no judgment is made on whether the fetched result is empty and fetched directly index:0,size:0
It can operate normally after adding if judgment:
String select_sql = "select cguid,(case isrz when 1 then 'PASS' when 0 then 'FAIL' end) as smrzzt from t_jb_user where mobile=?"; List<Map<String,Object>> list = ydbsDaoI.findList(select_sql, new Object[]{phoneno}); if(list != null && list.size() > 0){ //Take out the result of the query String cguid = list.get(0).get("cguid")==null?"":list.get(0).get("cguid").toString(); String smrzzt = list.get(0).get("smrzzt")==null?"":list.get(0).get("smrzzt").toString(); } else { return; }
Similar Posts:
- How to Solve Request processing failed; nested exception is java.lang.NullPointerException
- Convert Object to List>, avoiding Unchecked cast: ‘java.lang.Object’ to ‘java.util.List
- hibernate java.lang.StackOverflowError: null
- Python: `if not x:` VS `if x is not None:` VS `if not x is None:`
- Several cases of error reporting in java.lang.nullpointerexception
- com.sun.jdi.InvocationException occurred invoking method
- [Solved] Java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
- [leetcode] 140. Word break II word split II
- Transcoding of system.web.httputility.urlencode in C #
- A brief summary of hash calculation in resource packaging of unity