I run a Tomcat 7 web application on 2 locations; in one location there is a MySQL database, in the other a SQL-Server. In the context.xml file of the webapp I defined two <Resources>
that contain the database connection information for both databases.
Because I am still developing I sometimes run the application with the MySQL server (at home), and sometimes with the SQL-server (at work).
Until now I have been recompiling the code every time to either connect to MySQL or SQL-Server, by changing change the line
//connect to MySQL
DataSource ds = (DataSource) env.lookup( "jdbc/mysql" );
into
//connect to SQL-Server
DataSource ds = (DataSource) env.lookup( "jdbc/sqlserver" );
Is there a simple(r) way to let the web application know on which location I am, for example with a setting in a xml file, so that the webapp knows with which database it has to connect?