始终无法进入while函数

package Dao;


import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;


import Bean.login;

import Util.DBUtil;


public class loginDao {

private static String user = "aaa";

Connection con = null;

PreparedStatement stmd = null;

ResultSet rs = null;


public  Bean.login login(String user) throws SQLException{

//String user1 = "'aaa'";

System.out.println("ld2");//static Bean.login根据提示修改

String sql = "select * from user where name =?";

System.out.println("ld3");

con = DBUtil.getConnection();

System.out.println("ld4");

stmd = con.prepareStatement(sql);

stmd.setString(1,user);

System.out.println("ld5");

rs = stmd.executeQuery();

System.out.println("ld6");

while(rs.next()){

System.out.println("ld7");

login u = new login();

System.out.println("ld8");

    u.setUser(rs.getString("name"));

    u.setPassword(rs.getString("password"));

    System.out.println("ld9");

    return null;

}

return null;

}

public static void main(String[] args){

loginDao ld = new loginDao();

try {

ld.login("aaa");

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

System.out.println("ld1");

}

}


枫夜流萤
浏览 1268回答 2
2回答

东风冷雪

while(rs.next())肯定不满足  循环 条件啊。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java