Hibernate Software can work with three types of
connection pool. They are
1.Hibernate software
supplied built-in connection pool.
2.Third party supplied
connection pool, like c3p0 proxool
3.Web
Server/Application Server managed JDBC Connection poll.
Working with C3PO JDBC Connection pool in our hibernate
application
Step-1:
Configuration file
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/abc</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.max_size">30</property>
<property name="hibernate.c3po.min_size">5</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<mapping resource="emp.hbm.xml"/>
</session-factory>
Step2: mapping file same
Step3: client application is same…. And extra jar file i.e
Just run the program
For
Example project
Procedure
to Work with Proxool JDBC Connection Pool
in our hibernate application
Step:1
Add Proxool pool related connection provider class in HB
Configuration file.
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>
<property name="hibernate.proxool.pool_alias">mypool1</property>
<property name="hibernate.proxool.xml">myfile.xml</property>
<mapping resource="emp.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Step2:
Myfile.xml
<proxool-config>
<proxool>
<alias>mypool1</alias>
<driver-url>jdbc:mysql://localhost/abc</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user"
value="root"></property>
<property name="password"
value=""></property>
</driver-properties>
<minimum-connection-count>10</minimum-connection-count>
<maximum-connection-count>20</maximum-connection-count>
</proxool>
</proxool-config>
Step3: Mapping file and client application is same
Step4: run the application
For Example Project
No comments:
Post a Comment