建表语句和表的数据,以及范例如下:
第1种:直接使用where
id,
username,
password,
sex,
输入:username:Tom,password:123
2018-02-03 11:54:57,458 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (10629ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE username = ? and password = ?
2018-02-03 11:54:57,710 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (10881ms)] - ==>
Parameters: Tom(String), 123(String)
2018-02-03 11:54:57,913 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (11084ms)] - <==
Total: 1
输入:username:Tom,password:为空
2018-02-03 15:51:51,635 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (15115ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE username = ? and password = ?
2018-02-03 15:51:51,697 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (15177ms)] - ==>
Parameters: Tom(String), (String)
2018-02-03 15:51:51,729 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (15209ms)] - <==
Total: 0
第2种:使用
id,
username,
password,
sex,
输入:username:Tom,password:123
2018-02-03 15:41:23,540 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (14556ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE username =? and password = ?
2018-02-03 15:41:23,572 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (14588ms)] - ==>
Parameters: Tom(String), 123(String)
2018-02-03 15:41:23,618 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (14634ms)] - <==
Total: 1
输入:username:Tom
2018-02-03 15:41:40,974 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (31990ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE username =?
2018-02-03 15:41:40,975 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (31991ms)] - ==>
Parameters: Tom(String)
2018-02-03 15:41:40,975 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (31991ms)] - <==
Total: 2
输入:username:为空,password:为空
2018-02-03 15:50:12,162 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (69422ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user
2018-02-03 15:50:12,162 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (69422ms)] - ==>
Parameters:
2018-02-03 15:50:12,162 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (69422ms)] - <==
Total: 3
第3种:使用
id,
username,
password,
sex,
2018-02-04 11:43:59,272 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (11729ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE username =? AND password =?
2018-02-04 11:43:59,537 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (11994ms)] - ==>
Parameters: Tom(String), 123(String)
2018-02-04 11:43:59,725 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (12182ms)] - <==
Total: 1
2018-02-04 11:51:03,690 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (34742ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE username =?
2018-02-04 11:51:03,690 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (34742ms)] - ==>
Parameters: Tom(String)
2018-02-04 11:51:03,690 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (34742ms)] - <==
Total: 2
2018-02-04 11:51:36,346 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (67398ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE password =?
2018-02-04 11:51:36,346 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (67398ms)] - ==>
Parameters: 123(String)
2018-02-04 11:51:36,362 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (67414ms)] - <==
Total: 1
第4种:使用
id,
username,
password,
sex,
2018-02-04 11:46:10,148 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (12238ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE username =? AND password =?
2018-02-04 11:46:10,413 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (12503ms)] - ==>
Parameters: Tom(String), 123(String)
2018-02-04 11:46:10,600 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (12690ms)] - <==
Total: 1
2018-02-04 11:47:33,979 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (13198ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE username =?
2018-02-04 11:47:34,244 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (13463ms)] - ==>
Parameters: Tom(String)
2018-02-04 11:47:34,432 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (13651ms)] - <==
Total: 2
2018-02-04 11:49:00,977 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (100196ms)] - ==>
Preparing: SELECT id, username, password, sex FROM t_user WHERE password =?
2018-02-04 11:49:00,977 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (100196ms)] - ==>
Parameters: 123(String)
2018-02-04 11:49:00,993 -[DEBUG] method:[com.springmvc.dao.UserDao.findByUsernameAndPwd (100212ms)] - <==
Total: 1
以上基于JDK1.8。日志为亲测。