3

It is hard to find a resource on this without finding Java EE, but here is what I am looking for:

All I have is a standard Java SE app, it makes a lot of DB connections. I simply need to make use of a connection pool. Any suggestions?

Arjan Tijms
  • 37,353
  • 12
  • 107
  • 135
Zombies
  • 23,881
  • 41
  • 137
  • 219
  • 1
    How else does one connect to a database using Java? – duffymo Mar 07 '10 at 14:50
  • JDBC drivers all use sockets to do the low level reading/writing of data to the DB. Only a nut would do it this way if a JDBC driver is available. – mP. Mar 08 '10 at 00:48

6 Answers6

5

I would suggest c3p0. There is also this other question which discusses c3p0 vs DBCP and several stand-alone connection pools.

Community
  • 1
  • 1
ewernli
  • 37,202
  • 4
  • 88
  • 121
3

Here are two options that don't require any Java EE:

C3P0 - I have used this pool library for a long time in a Java SE app but it does not support the new Java 6 JDBC interfaces. You can still use the pool Java 6 but if you try and call any of the new methods an exception is thrown saying that the method is not implemented.

DBCP - I have never used this connection pool myself but I have seen various posts about it, and it does support the new JDBC features added in Java 6

Arjan Tijms
  • 37,353
  • 12
  • 107
  • 135
Yanamon
  • 630
  • 3
  • 11
  • 1
    In DBCP everything is synchronized to a single thread. If your app is multiuser/multithreaded, C3P0 is a better choice. – BalusC Mar 07 '10 at 15:03
3

Can I also suggest BoneCP (http://jolbox.com) ? It is currently the fastest connection pool available and offers a good feature set.

wwadge
  • 3,486
  • 1
  • 17
  • 28
  • 1
    It looks like [over here](http://stackoverflow.com/a/1662916/311525) you now feel that there is another connection pool which is faster. – Scott Dec 30 '13 at 16:56
2

javax.sql.DataSource provides a connection pool, and most DB vendors provide an implementation of DataSource.

user207421
  • 298,294
  • 41
  • 291
  • 462
1

Take a look at HikariCP. Even BoneCP's author admits it is now the king of the hill.

Community
  • 1
  • 1
Scott
  • 16,401
  • 14
  • 71
  • 118
1

Here is a list of Java connection pool libraries. I have only used c3po out of these, as part of Hibernate, and so far it works fine (as much as I actually see of it... but I guess if I rarely ever notice the connection pooling software I am using, then it is working well ;-)

Péter Török
  • 112,083
  • 30
  • 265
  • 327