|
-
April 30th, 2010, 08:11 AM
#1
help with jList and arraylist
Hello! I'm pretty new to java and programming and general and could need some help with how to solve the problem I'm having.
Here are the two classes I have that covers this part:
public class deltagarinmat {
dbconnection dbcon = new dbconnection();
ResultSet rs = dbcon.getData("SELECT * FROM deltagare");
public List<deltagare> getAllPeople() {
List<deltagare> data = null;
try {
data = new ArrayList<deltagare>();
while (rs.next()) {
deltagare delt = new deltagare();
int nr = rs.getInt(1);
String name = rs.getString(2);
String username = rs.getString(3);
String password = rs.getString(4);
delt.setPersNR(nr);
delt.setNamn(name);
delt.setLogin(username);
delt.setPass(password);
data.add(delt);
}
} catch (SQLException e) {
} finally {
return data;
}
}
}
AND
public class deltagare {
private int persNR;
private String namn;
private String login;
private String pass;
public deltagare() {
}
public deltagare(int nr, String name, String username, String password) {
setPersNR(nr);
setNamn(name);
setLogin(username);
setPass(password);
}
public int persNR() {
return persNR;
}
public void setPersNR(int persNR) {
this.persNR = persNR;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getNamn() {
return namn;
}
public void setNamn(String namn) {
this.namn = namn;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
}
These are the two classes I have to first get the data from my database into a arraylist. And then a simple class with set and get. I would like to make a jList with the data I got in my arraylist. But I don't really know how to do it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|