0

I am totally familiar with connection pool libraries, like c3p0, etc... I'm cool with connection pools that are managed by a web container, like Tomcat and WebSphere.

But what about the scenario where you have a stand alone, batch mode Java application (something with a main method) and you want it to be able to take advantage of connection pooling? I mean, if the stand alone program was to manage the pool, it would run, create the pool, use the connections then exit, destroying the pool. This doesn't really buy you anything if you want the application to run and make use of an existing connection pool.

what I am asking is, is there a layer of software than can run in between the database and the Java command line application that can manage the connection pool? This software would provide a port for your Java application to access through JDBC to the connection pool. Any application with a JDBC URL pointing to this port would thereby have use of the connection pool. Now, standalone applications can make use of connection pooling, even though no middleware server (tomcat, glassfish) is there.

Sounds cool. Does it exist? And does it exist for Oracle :)

Ron Klein
  • 9,178
  • 9
  • 55
  • 88
  • 1
    A stand-alone batch application probably needs just one or two connections. Why not simply avoid using a pool completely, or use a local pool with a minimal number of connections? – JB Nizet Jul 28 '13 at 08:18
  • A standalone application may need a connection pool for the same reason that an application running in a container needs one: To not crash when what would otherwise be a single connection times out or gets bad for other reasons. Instead of using a connection directly, the application uses a DataSource to fetch good connections when required. The DataSource then provides the reliability that a Connection in isolation cannot provide. – user250343 Jul 14 '16 at 02:27

2 Answers2

0

I didn't test it, but it looks interesting:

DBPool : Java Database Connection Pooling

What is DBPool?

A Java-based database connection pooling utility, supporting time-based expiry, statement caching, connection validation, and easy configuration using a pool manager.

Ron Klein
  • 9,178
  • 9
  • 55
  • 88
0

As I understand your setup the pool must be a standalone process. This means, that the batch uses the right JDBC driver for the database but should talk to the pool. This means, that the pool must talk the proprietary protocol of the database. This cannot be done by one product with reasonable effort.

Therefore you should not ask for a general solution but for solutions for a specific database.

For PostgreSQL for example there are two such pools: PgBouncer and pgpool.

A.H.
  • 63,967
  • 15
  • 92
  • 126