Different web applications use the same connection pool

Asked

Viewed 31 times

1

Hello! I have two Webs applications that are connected to a single database in the bank, how do I make them enjoy the same connection pool? I create the c3p0 variables in the persistence.xml of both, or just one? Thanks!

1 answer

2

As far as I know, this is not possible. Each application has its own separate connection pool. I don’t know solutions that seek to share connections pools between different applications.

What you could do is create a third application that is responsible for accessing the database and make the other two applications (or as many others) access it via REST+HTTP+JSON, or via XML+SOAP, via socket, via RMI, or anything like that. That is, the idea would be to encapsulate all access to the database in a webservice that holds exclusive access to the connection pool.

  • 1

    I think it goes with JNDI... but I wouldn’t recommend

  • Okay, thanks for your attention!

  • 1

    I agree with Victor, I don’t know if it makes sense for you to share the pool on your own, maybe what’s more coherent is sharing cache through a distributed cache, but this is more about performance (queries and access to the bank), not sharing connections pool.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.