Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share connection pool among multiple Java applications

I'm implementing several JavaSE applications on single server. Is it possible to setup a single connection pool (e.g. C3P0) and share among these applications? I just want to have an easy way to manage the total number of DB connections.

Is there any drawbacks using such centralized connection pool?

Thank you, Wilson

like image 426
Wilson Avatar asked May 03 '10 17:05

Wilson


People also ask

How many connections can you have in a pool?

A pool contains two types of connections: Active connection: In use by the application. Idle connection: Available for use by the application.

How many connection pools should I have?

For optimal performance, use a pool with eight to 16 connections per node. For example, if you have four nodes configured, then the steady-pool size must be set to 32 and the maximum pool size must be 64.

How do you do connection pooling?

Connection pooling means that connections are reused rather than created each time a connection is requested. To facilitate connection reuse, a memory cache of database connections, called a connection pool, is maintained by a connection pooling module as a layer on top of any standard JDBC driver product.


1 Answers

You can simply use the same data source defined in the server for all application to share the same DB connection pool easily.

One obvious drawback would be that performance of independent application may degrade due to a load on totally unrelated application which would be hard to figure out.

like image 189
Fazal Avatar answered Sep 28 '22 18:09

Fazal