That depends on who's managing the datasource.
If you're manually constructing and managing the datasource in your own webapp like so new SomeDataSource()
, etc, then the JDBC driver JAR file can be placed in webapp's /WEB-INF/lib
. But if appserver happen to provide the very same JDBC driver JAR file in its own /lib
already, then you could also just make use of it.
However, if you're instructing appserver to manage the datasource all by itself and you're merely making use of it in your webapp via @Resource
, etc, then the JDBC driver JAR file has to be placed in appserver's own /lib
, for the very simple reason because the data source is prepared on appserver's startup completely independently from any (to be) deployed web applications. This data source is in turn shareable among all webapps. It would technically just not work if the JDBC driver JAR file is in one of the yet-to-be-deployed webapps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…