Questions tagged [connection-pooling]

In software engineering, a connection pool is a cache of connections maintained so that the connections can be reused when future requests to the resource are required.

Description

Connection pools are used to enhance the performance of executing commands on a database or other server. Opening and maintaining a connection for each user especially requests made to a dynamic database-driven website application, is costly and wastes resources.

In connection pooling, after a connection is created, it is placed in the pool and it is used over again so that a new connection does not have to be established. If all the connections are being used, a new connection is made and is added to the pool. Connection pooling also cuts down on the amount of time a user must wait to establish a connection to the resource.


Connection Pool libraries

Java

  • HikariCP
    It is considered as one of the best libraries for connection pooling. Play 2.4 Framework uses HikariCP by default.
    Website, GitHub.

  • BoneCP
    It beats older connection pools such as C3P0 and DBCP but should now be considered deprecated in favour of HikariCP.
    Website, GitHub

  • Apache Commons DBCP
    Website.

  • C3P0
    Website, GitHub

3263 questions
37
votes
3 answers

How to Debug / Log Tomcat JDBC Connection Pool's connections?

I am using Tomcat JDBC connection pool along with Spring boot, JDBC template and SQL Server. I need to know what is going inside connection pool while application is waiting for database connection. Such as.... No of active connections No of idle…
Sundararaj Govindasamy
  • 8,180
  • 5
  • 44
  • 77
37
votes
1 answer

How Jedis Pool works?

I'm using Jedis pool to manage connections to Redis server. An example code of mine as follows: public Set getTopArticleList(int start, int end) { Set list = null; Jedis j =…
ipkiss
  • 13,311
  • 33
  • 88
  • 123
37
votes
2 answers

Correct way to keep pooled connections alive (or time them out and get fresh ones) during longer inactivity for MySQL, Grails 2 app

I have a grails app that has flurries of high activity, but then often periods of inactivity that can last several hours to over night. I notice that the first users in the morning get the following type of exception, and I believe this is due to…
Peter
  • 29,498
  • 21
  • 89
  • 122
34
votes
1 answer

Threading error when using `ActiveRecord with_connection do` & ActionController::Live

Major edit: Since originally finding this issue I have whittled it down to the below. I think this is now a marginally more precise description of the problem. Comments on the OP may therefore not correlate entirely. Edit lightly modified version…
34
votes
6 answers

How to detect SqlServer connection leaks in a ASP.net applications?

I'm currently doing some GUI testing on a ASP.net 2.0 application. The RDBMS is SQL Server 2005. The host is Win Server 2003 / IIS 6.0. I do not have the source code of the application because it was programmed by an external company who's not…
34
votes
2 answers

How does pgBouncer help to speed up Django

I have some management commands that are based on gevent. Since my management command makes thousands to requests, I can turn all socket calls into non-blocking calls using Gevent. This really speeds up my application as I can make requests…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
33
votes
4 answers

Am I Using JDBC Connection Pooling?

I am trying to determine if I am actually using JDBC connection pooling. After doing some research, the implementation almost seems too easy. Easier than a regular connection in fact so i'd like to verify. Here is my connection class: public class…
ryandlf
  • 27,155
  • 37
  • 106
  • 162
33
votes
10 answers

Need Code to create Connection Pool in java

Need code to create the connection pool in java? How does we make sure that connection pool doesn't return the same object which is already in use? How happens if client closed the connection after taking it out from Connection pool? Update 1: I…
mohan
  • 487
  • 1
  • 5
  • 5
33
votes
2 answers

“error: 19 - Physical connection is not usable” with OWIN access in Azure database

I have tried all the other postings on the dreaded "error 19" and found that the few with answers do not apply or do not help, hence this new post. This is a very serious potential problem for all Azure+EF users. First occurrence: I am using the…
iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
32
votes
2 answers

How rails database connection pool works

I am learning rails database connection pool concept. In rails application I have defined pool size of 5. my understanding about connection pool size is as below. When server start rails automatically creates n number of connection defined in the…
32
votes
6 answers

How to set application_name for postgres connections?

I'm using tomcat connection pool org.apache.tomcat.jdbc.pool.DataSource. The connections appear in my database pg_stat_activity with empty application_name. How could I set that application name in my java app, so I know where each connection comes…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
32
votes
2 answers

hibernate connection pool

I can't seem to get hibernate to use c3p0 for connection pooling, it says 12:30:35,038 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!) 12:30:35,038 INFO…
user217631
  • 1,278
  • 5
  • 18
  • 33
32
votes
6 answers

Is there any way to have the JBoss connection pool reconnect to Oracle when connections go bad?

We have our JBoss and Oracle on separate servers. The connections seem to be dropped and is causing issues with JBoss. How can I have the JBoss reconnect to Oracle if the connection is bad while we figure out why the connections are being dropped in…
Joshua
  • 26,234
  • 22
  • 77
  • 106
31
votes
4 answers

JDBC Connection pooling using C3P0

Following is my helper class to get DB connection: I've used the C3P0 connection pooling as described here. public class DBConnection { private static DataSource dataSource; private static final String DRIVER_NAME; private static final…
jai
  • 21,519
  • 31
  • 89
  • 120
30
votes
11 answers

C3P0 apparent deadlock when the threads are all empty?

I'm using C3P0 as a connection pool in Tomcat, and I'm seeing very worrying errors: 2010-09-16 13:25:00,160 [Timer-0] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner -…
Steven Schlansker
  • 37,580
  • 14
  • 81
  • 100