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");
}
}
东风冷雪
相关分类