querycontainer statement lifecycle

Hello! I prototyped querycontainer for pushing data from database to table but as querycontainer keeps sql statement open we would have way too many statements waiting to be closed on our database. We got no logout procedure on our application as it’s public site. Each user consumes tens of big read only sql objects and as user count grows, I think that this becomes an issue on production site. I did not quite catch your collection class ideas, it should not be so hard to undestand…maybe I need to check it more…

So, how would you fix this??

What would be the optimal way of closing the result-set in your case?

(i.e. what kind of API should be provided)

You are right, QueryContainer does not “Late open and Close Fast” - it closes the statement in finalize() (or by explicit call).

However, before we enhance QueryContainer, you can copy QueryContainer’s contents to Java “POJO” side using IndexedContainer like this:


try {
			QueryContainer qc = new QueryContainer("SELECT * FROM employee",
					sampleDatabase.getConnection());
			IndexedContainer ic = new IndexedContainer(qc.getItemIds());
			qc.close();
			table.setContainerDataSource(ic);
		} catch (SQLException e) {
			e.printStackTrace();
		}

ehh… I already hacked this “manually” directly to my table… tried this too but it only copies items?

You have to: 1) create indexed container, 2) copy properties, 3) copy all properties of all rows. Surely there should be a “instantiateFromAnotherContaner” constructor…