我用spring jdbc template操作数据库,当我需要验证用户登陆的用户名和密码时传入两个参数userName和password,但是我怎么从数据库中select出同时满足这两个条件的User?????我现在的做法是queryForObject(sql, RowMapper)返回一个User对象,然后再去getUsername和getPassword,再做比对。但个人觉得这样比较麻烦。就不能select * from user_table where userName=? and password=? 一样的办法吗?或者说就不能有同时加入两个参数的查询吗??渣渣求大神指教!!!
2条回答 默认 最新
- hqr_1988 2015-03-30 08:07关注
简单的返回一个int参数就行 如果是0说明不存在
return queryForInt("select count(*) from user_tb where user_name=? and user_password=? ",new Object[]{name,password},RowMapper);本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报