ProduktTO ist eine Transferklasse, wo nur Getter und Settermethoden enthalten sind.
unter anderem diese
[code=Java]public List<ProduktTO> getProducts() {
return products;
}
public void setProducts(List<ProduktTO> products) {
this.products = products;
}[/code]
Ich hole mir die Produkte von einer Datenbank mit
[code=Java]public List<ProduktTO> selectAllProducts() {
List<ProduktTO> list = new ArrayList<ProduktTO>();
Statement stmt = null;
ResultSet rs = null;
try {
stmt = con.createStatement();
String strSQL = "SELECT * from tblProdukt ORDER BY ProdId";
rs = stmt.executeQuery(strSQL);
while (rs.next()) {
ProduktTO to = new ProduktTO();
to.setProdId(rs.getString(1));
to.setProduktArt(rs.getString(2));
to.setBezeichnung(rs.getString(3));
to.setGewicht(rs.getBigDecimal(4));
to.setRundfaktor(rs.getBigDecimal(5));
to.setAbschlag(rs.getBigDecimal(6));
to.setAufschlag(rs.getBigDecimal(7));
to.setVkfA(rs.getBigDecimal(8));
to.setVkfB(rs.getBigDecimal(9));
to.setVkfC(rs.getBigDecimal(10));
to.setKaufA(rs.getBigDecimal(11));
to.setKaufB(rs.getBigDecimal(12));
to.setKaufC(rs.getBigDecimal(13));
list.add(to);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
rs.close();
stmt.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return list;
}[/code]
Vielen Dank und liebe Grüße
JDK