Connection Pooling
Connection pooling, but what it is and what it do ?
It is set of database connections that can be used in future. This connection can be used across many sessions, once execution completes, it returns connection to connection pool.
Source: docs.oracle.com
It will boost performance, because creating connection for every-user and action it will degrade performance, So how can we add connection pooling in java.
Hibernate configuration using c3p0
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost/connectionpool
hibernate.connection.username=root
hibernate.connection.password=<password>
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.show_sql=false
hibernate.c3p0.max_size=1
hibernate.c3p0.min_size=0
hibernate.c3p0.timeout=5000
hibernate.c3p0.max_statements=100
hibernate.c3p0.idle_test_period=300
hibernate.c3p0.acquire_increment=2
For more information, check Documentation
Another connection pooling implementation using Apache DBCP
Happy Connection pooling.
Comments
Post a Comment