public User selectInformation(User u){ User u1=new User(); try{ Connsql connsql=new Connsql(); Connection con=connsql.getConnection(); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from user where name='"+u.getUserName()+"';"); if(rs!=null){ while(rs.next()){ String str1=rs.getString(1); String str2=rs.getString(2); u1.setUserName(str1); u1.setUserPassword(str2); } } stmt.close(); con.close(); } catch(Exception e){ } return u1; }
public class User { private String userName; private String userPassword; public void setUserName(String userName){ this.userName=userName; } public void setUserPassword(String userPassword){ this.userPassword=userPassword; } public String getUserName(){ return userName; } public String getUserPassword(){ return userPassword; }