-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Daniel,
On 7/19/2010 11:19 AM, Daniel Plappert wrote: > It is possible to declare the datasource in the servlet.xml and > reference it in the web.xml of the application (via jndi)[?] Assuming you meant "server.xml", then yes, you can define it globally and reference it locally. Look under the configuration reference for your Tomcat version for "Global Resources" a.k.a. <GlobalNamingResources>. > Or one can declare it in the application itself, i.e. in > application-context.xml. The first one declares the datasource for > all applications deployed in this servlet-container, the second one > is only for the application. Right. > Is there a good reason for declaring the datasource in servlet.xml, > other than to "share" the datasource with multiple applications? I can think of several reasons you might want to do this, including but not limited to any of the following: 1. There really is a database that should be shared by a number of different applications, and they should all use the same pool of connections 2. The developers have no idea about the data source connection details, and expect the server admins to provide the configuration #2 isn't really a good reason to do this, though: the server admins can always provide or override a webapp-provided context.xml file in order to include the correct configuration. This allows you to change the configuration without starting the entire server: only a webapp restart/redeploy is necessary. > Shouldn't every application have their own datasource? That depends entirely on your own requirements. > Which type of declaration do you prefer? I would recommend per-webapp configuration, but sometimes it makes sense to share a connection pool across many webapps. Again, it depends entirely upon your own requirements. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxEdocACgkQ9CaO5/Lv0PDOSQCfcNKLkXM+F/IkEgkXa7aWDwxH zlAAoLFCl9AJ0YEheFotb+mfC7ZZV6Za =xB3n -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org