I have several different databases for different environments to connect my application to. These are constant per installation but differ between them. In other words there
Use placeholders for the url, user and password in the config file, and replace those placeholders with actual values when building the application (using ant, Maven, or whatever you use to build your application). The build process itself could take those values from a profile (if using Maven), or from environment variables, or from command-line arguments.
You just need to build the application three times, with different parameters : once for each target environment.