Recently I've decided to move from Common DBCP to Tomcat JDBC Connection Pool. I changed bean description (using spring 3.1 + hibernate 4 + tomcat) and was faced with the next issue on my web app start up:
HHH000342: Could not obtain connection to query metadata : com.mysql.jdbc.Driver
and then when I try to query db from my app I am getting:
23:04:40,021 WARN [http-bio-8080-exec-10] spi.SqlExceptionHelper:(SqlExceptionHelper.java:143) - SQL Error: 0, SQLState: null
23:04:40,022 ERROR [http-bio-8080-exec-10] spi.SqlExceptionHelper:(SqlExceptionHelper.java:144) - com.mysql.jdbc.Driver
I must have done something wrong with configuration so hibernate cannot obtain connection but do not see it. really appreciate if you can point me to the right direction.
here is piece of my datasource bean definition
<bean id="jdbcDataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy- method="close"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://127.0.0.1:3306/test"
p:username="root"
p:password="test"
p:defaultAutoCommit="false"
p:maxActive="100"
p:maxIdle="100"
p:minIdle="10"
p:initialSize="10"
p:maxWait="30000"
p:testWhileIdle="true"
p:validationInterval="60000"
p:validationQuery="SELECT 1"
p:timeBetweenEvictionRunsMillis="60000"
p:minEvictableIdleTimeMillis="600000"
p:maxAge="360000"
/>
and here is how I tie it with spring's session factory
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="jdbcDataSource" />...
after migration, I forgot to add lib tomcat-jdbc to my classpath :) now it wroks