public class DB_login {
private Statement st;
public DB_login() {
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:1000/login";
Connection con = (Connection) DriverManager.getConnection(url, "root", "kaje");
st = (Statement) con.createStatement();
} catch (ClassNotFoundException e) {
System.out.println("classnotfound");
} catch (SQLException f) {
System.out.println("sqlexception");
}
}
public List openUser() {
ArrayList userlist = new ArrayList();
User tempUser;
try {
ResultSet rs = st.executeQuery("SELECT * from logindet");
while (rs.next()) {
String username = rs.getString("username");
System.out.println(username);
String password = rs.getString("password");
System.out.println(password);
tempUser = new User(username, password);
userlist.add(tempUser);
}
} catch (SQLException e) {
System.out.print("exception1");
}
return userlist;
}
}