在ibatis中执行select查询,为什么查询结果总是null
1个回答
推荐于2016-04-09
展开全部
<select id="getAdminByNameAndPasswd" parameterClass="java.util.Map" resultClass="Admin">
select * from admin_info where name=#name# and passwd=#passwd#
</select>
相关的java代码如下:
public Admin getAdminByNameAndPwd(String name, String pwd) throws SQLException {
Map map = new HashMap();
map.put("name", name);
map.put("pwd", pwd);
Admin admin = (Admin) sqlMapClient.queryForObject("admin.getAdminByNameAndPasswd",map);
if (admin != null) {
System.out.print("get admin by name and pwd sucess!");
return admin;
} else {
System.out.print("get admin by name and pwd false,you will be get the null!");
return null;
}
}
select * from admin_info where name=#name# and passwd=#passwd#
</select>
相关的java代码如下:
public Admin getAdminByNameAndPwd(String name, String pwd) throws SQLException {
Map map = new HashMap();
map.put("name", name);
map.put("pwd", pwd);
Admin admin = (Admin) sqlMapClient.queryForObject("admin.getAdminByNameAndPasswd",map);
if (admin != null) {
System.out.print("get admin by name and pwd sucess!");
return admin;
} else {
System.out.print("get admin by name and pwd false,you will be get the null!");
return null;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询