I\'m trying to figure out how my Spring app can determine where it is deployed and load the appropriate datasource. We have 3 environments...my local, the development server, a
For data sources the easiest way would be to define data sources and let the container manage the connection pooling.
To do so, define a resource reference to the data source in web.xml
DB Connection
jdbc/MyDataSource
javax.sql.DataSource
Container
and reference it in spring as such:
then you can define the data source in the application server, which means you can change the underlying database. In case of websphere, this would be done through the websphere console. In case of tomcat, it would be done through the Context.xml:
...
That way you only need to change the context to deploy to development, test and production and don't tie your application to a specific database.