做jdbc的时候碰到点问题

输入正确的用户名和密码 会登陆成功
数据库里面我查看了,用了正确的用户名和密码但是输出结果是登陆失败
问题相关代码

public class JDBCtest06 {
public static void main(String[] args) {
//初始化一个界面
Map<String,String> userLoginInfo = 初始化界面();
//验证用户名和密码
boolean loginSuccess = login(userLoginInfo);
//输出结果
System.out.println(loginSuccess ? "登陆成功" : "登陆失败");

}
/*用户登录
 * userLoginInfo 用户登录信息
 * false表示失败,true表示成功*/

private static boolean login(Map<String, String> userLoginInfo) {
    //打标记
    boolean loginSuccess =false;
    //单独定义变量
    String loginName =userLoginInfo.get("loginName");
    String loginPwd =userLoginInfo.get("loginPwd");

    //JDBC代码
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;

    try {

        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/lianxisheng","root","333");
        stmt = con.createStatement();
        String sql = "select * from user where loginName = '"+ loginName +"' and loginPwd = '"+ loginPwd +"'";
        rs = stmt.executeQuery(sql);//
        if(rs.next()){

// 登陆成功
loginSuccess = true;
}
} catch (Exception e) {
e.printStackTrace();
}finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (con != null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
return loginSuccess;
}

/*
 * 初始化用户界面*/
private static Map<String, String> 初始化界面() {
    Scanner s = new Scanner(System.in);
    System.out.println("用户名:");
    String loginName = s.nextLine();
    System.out.println("密码:");
    String loginPwd = s.nextLine();
    Map<String,String> userLoginInfo= new HashMap<>();
    userLoginInfo.put("loginName",loginName);
    userLoginInfo.put("password",loginPwd);
    return userLoginInfo;
}

}

用户名和密码字段是char类型,还是varchar类型,如果是char类型,数据库会自动补齐空格。