views:

61

answers:

2

I'm trying to creating a web app using GWT. In my application, I use MySQL as database. I tried to use a connection pool to control the number of connections to the database. However, Google web toolkit doesn't support CachedRowSet, which prevent me from closing the connections. Does any one know a walk around for this? (except making a deep copy of the ResultSet)

A: 

You need to realise that even though you are writing GWT in Java, it's actually been compiled into Javascript. Now sit down and have a think about how on earth javascript running in someone's browser is going to close your connections back on your server. Your intention seems to be lazy loading on the client side, and that is just not going to happen. Once you get over this mental hurdle, things will flow a lot more smoothly :)

If you want to use GWT you need to re-think your approach. You need to remember that all your data is disconnected from your server once it's used in GWT code, and runs as javascript once compiled. So yes, you need to move your data into appropriate POJOs and pass those to the client instead. Don't go crazy and try to transfer your entire database to your client, simple extract the parts you need...

rustyshelf
Actually the question isn't quite as illogical as your answer makes it seem. A CachedRowSet can be seen as disconnected set of results. One of it's uses is for passing data backwards and forwards between the server and a thin client.
BenM
A: 

I think the best approach would be to make a deep copy of the result set into a List of Maps. Each element in the list would be a map or the row in the result set where the map key is the column name and the value is the column value. If you want to be able to sync data back from the client this would be quite a bit more complicated.

BenM