java - Where should the JDBC driver JAR files reside on a Tomcat deployment with a datasource? -
i have java web application using spring, hibernate, tomcat7 & mysql. use datasource database operations. not clear standard location load jar files (tomcat-jdbc.jar & mysql-connector.jar) from? works if keep both jars either in catalina_home/lib/ or webapps/myapp/web-inf/lib. told use tomcat-jdbc catalina_home/lib/ , mysql-connector.jar /web-inf/lib/, gives classnotfound exception sql driver. can let me know right location these jars?
<bean id="datasource" class="org.apache.tomcat.jdbc.pool.datasource" destroy-method="close"> <property name="driverclassname" value="com.mysql.jdbc.driver" /> <property name="url" value="${db.url}" /> <property name="username" value="${db.username}" /> <property name="password" value="${db.password}" /> <property name="initialsize" value="${db.initialsize}" /> <property name="minidle" value="${db.minidle}" /> <property name="maxactive" value="${db.maxactive}" /> <property name="maxidle" value="${db.maxidle}" /> <property name="testwhileidle" value="${db.testwhileidle}" /> <property name="minevictableidletimemillis" value="${db.minevictableidletimemillis}" /> <property name="timebetweenevictionrunsmillis" value="${db.timebetweenevictionrunsmillis}" /> <property name="validationquery" value="${db.validationquery}" /> </bean>
that depends on who's managing datasource.
if you're manually constructing , managing datasource in own webapp new somedatasource(), etc, jdbc driver jar file can placed in webapp's /web-inf/lib. if appserver happen provide same jdbc driver jar file in own /lib already, make use of it.
however, if you're instructing appserver manage datasource , you're merely making use of in webapp via @resource, etc, jdbc driver jar file has placed in appserver's own /lib, simple reason because data source prepared on appserver's startup independently (to be) deployed web applications. data source in turn shareable among webapps. technically not work if jdbc driver jar file in 1 of yet-to-be-deployed webapps.
Comments
Post a Comment