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)
Google web toolkit doesn't work with CachedRowSet
198 views Asked by Progress Programmer AtThere are 2 answers
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...
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.