What kind of different ways are there for an Java web application to store the JDBC connection string and parameters?
The two ways of doing this that I am aware of is:
1. application side
2. environment side (JNDI)
Could someone elaborate on these? Like on the application side using a properties file. But is it possible to use an external properties file that multiple applications would have access to?
FYI: My environment includes Tomcat
The environment side has the advantage that it offers a single ready-to-use connection pool for all webapps, so that you don’t need to configure/program it from every individual webapplication on. The application side has the advantage that you have 100% control over it from the webapplication on. This advantage is however discutable; there’s potential code duplication and the maintenance is clumsy.
Yes, just put it in a shared classpath location (in Tomcat, you can set it by
shared.loaderproperty of/conf/catalina.properties). You only need to control the connection (pool) creation in every webapplication yourself. Using a JNDI connection pooled datasource is more recommended.