To provide a full example, this entry uses a simple web application written in Vaadin. I'm running it on a GlassFish 3.1.1 application server (supports Java EE 6), and the application talks to a PostgreSQL 9.1 database through a JDBC connection that's configured in the server. This means there's only one place I need to change my connection information once the data has been migrated.
The application itself is a very simple database for storing information about wine. I'll give a walkthrough of the application in a subsequent blog, followed by a version that runs on Tomcat that could be deployed to Amazon Elastic Beanstalk.
For better viewing, here is a direct link to the video embedded below.
After setting up the remote database in the cloud, the migration happens in three steps:
- Back up the existing database to a file.
- Restore the data into the new database.
- Point the application to the new database location (and restart if necessary).
Note that the GlassFish administration can be performed from the command line as well. To see a list of the properties that are set, you can use the asadmin "get" command and grep for the information (if you don't already know the property names):
BobbyMac}> ./asadmin get "*" | grep wine | grep property
Similarly, you can use the asadmin "set" command to change these values. Then you can redeploy the application to pick up the new values.