============问题描述============
实现用户登录功能,在手机客户端拿到用户的名称(username)和密码(password),然后在服务器端进行查询该用户,查询语句应该怎么写?我是这么写的;
// 创建数据库的链接,查询该用户 JDBConnection sqlConn = new JDBConnection(); sqlConn.executeQuery("select name,password from user_test where name = ‘" + username + "‘," + "password = ‘" + password + "‘");
然后报错you have an error in your SQL syntax;
是标点错了,哪位前辈能帮忙解决下,新手感激不尽
============解决方案1============
把“,” 换成 “and”试一下
select name,password from user_test where name=‘xxx‘ and password=‘xxx‘
============解决方案2============
条件里用and
时间: 2024-10-10 22:09:54