rs=st.executeQuery(sql);一直是红色显示无法解析Statement中的方法excuteQuery
package com.dao;
import com.Utils.JDBCUtil;
import com.model.Users;
import com.mysql.cj.xdevapi.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
public class UsersDao {
//1.校验登录信息是否在数据表中存在
public boolean IsLogin(Users users){
boolean isLogin=false;
if(users!=null){
Connection con= JDBCUtil.getCon();
Statement st=null;
ResultSet rs=null;
try {
//获取操作数据库的对象
st= (Statement) con.createStatement();
//拼接执行的sql语句
String sql="select count(*) as myCount from users where username='"+users.getUsername()+"' and password='"+users.getPassword()+"';";
System.out.println("查找用户信息的sql语句:"+sql);
//执行并接收返回的记录表
rs=st.executeQuery(sql);
System.out.println("查看执行用户信息的记录表");
String count="";
while (rs.next()){
count=rs.getString(1);
}
System.out.println("接收返回的总条数:"+count);
if (count.equals("1")){
isLogin=true;
}
System.out.println("返回验收结果是:"+isLogin);
}catch (SQLException throwables) {
throwables.printStackTrace();
}
}
return isLogin;
}
}