Hi,
We are currently checking out vaadin for our next generation project.
I tried to create a very quick and dirty app that uses the skeleton of the phonebook example.
but the datasource im using is from our staging db (via mysql jdbc connector)
When i’m inserting into the IndexedContainer 1,000,000 entries (with around 8 fields each) i’m getting the :
javax.servlet.ServletException: com.vaadin.server.ServiceException: java.lang.OutOfMemoryError: Java heap space
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:240)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
error.
I’m new to vaadin and my code probably not optimal:
here is my major change:
private static IndexedContainer createDummyDatasource() {
IndexedContainer ic = new IndexedContainer();
try {
Class.forName(“com.mysql.jdbc.Driver”);
// Setup the connection with the DB
Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:33306/OurDB", "root", "password");
// Statements allow to issue SQL queries to the database
Statement statement = connect.createStatement();
// Result set get the result of the SQL query
ResultSet resultSet = statement
.executeQuery("select p.firstName as firstName, p.lastName as lastName, e.* from Event e join Player p on p.id = e.player_id where e.id < 1000000");
for (String p : fieldNames) {
ic.addContainerProperty(p, String.class, "");
}
while( resultSet.next() ) {
// It is possible to get the columns via name
// also possible to get the columns via the column number
// which starts at 1
// e.g. resultSet.getSTring(2);
Object oid = ic.addItem();
ic.getContainerProperty(oid, FNAME).setValue(resultSet.getString("firstName") == null? "No name" : resultSet.getString("firstName"));
ic.getContainerProperty(oid, LNAME).setValue(resultSet.getString("lastName")== null? "No Last name" : resultSet.getString("lastName"));
ic.getContainerProperty(oid, "id").setValue(resultSet.getString("id"));
ic.getContainerProperty(oid, "sum").setValue(resultSet.getString("sum"));
ic.getContainerProperty(oid, "totalNum").setValue(resultSet.getString("totalNum"));
ic.getContainerProperty(oid, "brandId").setValue(resultSet.getString("brandId"));
ic.getContainerProperty(oid, "currency").setValue(resultSet.getString("currency"));
ic.getContainerProperty(oid, "type").setValue(resultSet.getString("type"));
ic.getContainerProperty(oid, "total").setValue(resultSet.getString("total"));
ic.getContainerProperty(oid, "player_id").setValue(resultSet.getString("player_id"));
}
}
catch(Exception e) {
System.out.println("sdf");
}
return ic;
}
any idea why that happens?
Thanks