a little help about datatable...
HI guys,
i'm a new user of JSF and now i'm descovering great possibilities offered by datatable.
I read the article on
http://balusc.xs4all.nl/srv/dev-j2p-dat.html#RetrieveAndStoreData,
i've found it excellent but there is a point that isn't me clear...
I've to show in a datatable a mysql table
utenti(firstName,lastName,city)
which its relative values..
i've developed a User class with the tree values as private variables and getter and setter methods...
publicclass Userimplements Serializable{
privatestaticfinallong serialVersionUID = 1;
private String firstName;
private String lastName;
private String city;
public User( String firstName, String lastName,String city
){
this.firstName = firstName;
this.lastName = lastName;
this.city = city;
}
public String getFirstName(){
return firstName;
}
publicvoid setFirstName(String firstName){
this.firstName =firstName;
}
public String getLastName(){
return lastName;
}
publicvoid setLastName(String lastName){
this.lastName = lastName;
}
public String getCity(){
return city;
}
publicvoid setCity(String city){
this.city = city;
}
}
and this is UsersTable
package giu;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
publicclass UsersTable{
private List myTableList;
publicvoid loadMyTableList(){
try{
Context ctx =new InitialContext();
if (ctx ==null){
thrownew Exception("Boom - No Context");
}
Context envCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("java:comp/env/MysqlJNDI");//"java:comp/env/jdbc/nomedb"
if (ds !=null){
Connection conn = ds.getConnection();
if (conn !=null){
PreparedStatement pst =null;
String query="SELECT * FROM utenti ;";
pst = conn.prepareStatement(query);
ResultSet res=pst.executeQuery();
pst.close();
conn.close();
setMyTableList(res.getOutputAsList());
}
}
}catch (Exception e){
e.printStackTrace();
}
}
public List getMyTableList(){
loadMyTableList();// Reload after every request.
return myTableList;
}
// Setters -
publicvoid setMyTableList(List myTableList){
this.myTableList = myTableList;
}
}
i have an error because i can't use getOutpusAsList on ResultSet res...
can you help me?
Please,i'm a bit confused on datatable,i'm trying to understand something....

