Hi to all!!
I am trying to use connection pooling in hibernate.
Server I am using is Tomcat5.0
database I am using is DB2 v-8.1
Connection is successful without connection pooling. Everything is working fine without it.
But when implementing connection pooling, I am getting the error.
Code:
"org.hibernate.exception.GenericJDBCException: Cannot open connection"
The context setting is:-
Code:
<Context docBase="HibernateOnlineTest2" path="/HibernateOnlineTest2" reloadable="true" source="org.eclipse.jst.j2ee.server:HibernateOnlineTest2">
<Resource
name="jdbc/hibernateTest"
auth="Container"
type="javax.sql.DataSource"
removeAbandoned="true"
removeAbandonedTimeout="30"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="administ"
password="ggsl"
driverClassName="com.ibm.db2.jcc.DB2Driver"
url="jdbc:db2://localhost:50000/hibernat"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"/>
</Context>
and a resource ref in web.xml
Code:
<resource-ref>
<description> DB Connection Pooling</description>
<res-ref-name> jdbc/hibernateTest</res-ref-name>
<res-type> javax.sql.DataSource</res-type>
<res-auth> Container</res-auth>
</resource-ref>
and using this resource ref in hibernate.cfg.xml
Code:
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="connection.datasource"> java:comp/env/jdbc/hibernateTest</property>
is this a problem of driver I am using(com.ibm.db2.jcc.DB2Driver), i.e. for implementing connection pooling we have to specify any other driver, if yes then which one.
I am using the following properties for connecting without connection pooling:
Code:
<property name="connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>
<property name="connection.url">jdbc:db2:hibernat</property>
<property name="connection.username">administ</property>
<property name="connection.password">ggsl</property>
<property name="connection.pool_size">10</property>
This way it is running fine.
Please help me out.