So far, I’ve implemented a little webapp with GWT, which works. But now I need to access a DB on the serverside. The problem: I have no idea on how to do this.
Problems I’m facing:
- Where to store/how to get the configuration for the DB (JNDI?)
- How to access the DB (connection pooling?)
Are there any good resources on that? Which are best practices for doing this?
I’m using GWT2.2, Jetty6 and the database is an MySQL-Database.
Yes and yes: on the server side you will always want to use jndi and connection pooling
JNDI is a common way to specify database connection so your app only needs to know its name, how to specify is container specific. Most often this will already include proper connection pooling. This is very important, you don’tknow how many concurrent connections are you going to have so without pooling you would blow your server up for sure.
Resources: aren’t any examples with GWT? I recall being able to create a bare server service using Eclipse plugin.
Best practise: keep your db connections as fast and as short as possible and give it back to pool as soon as you can.