wood burning stoves 2.0*
The moose likes JDBC and the fly likes Shared DB Connection Pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Shared DB Connection Pool" Watch "Shared DB Connection Pool" New topic
Author

Shared DB Connection Pool

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Anyone of you folks, know any framework/library/API which provide DB connection pool which can be shared among multiple applications. I mean, applications are deployed on separate machines, running under different JVMs, but sharing a single DB Connection Pool.

Thank you very much.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

any app server that provides JNDI can potentially allow external access to the JNDI resources and hence the DataSource managing Connections
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by David O'Meara:
any app server that provides JNDI can potentially allow external access to the JNDI resources and hence the DataSource managing Connections


Yup.

How about if no application server? I believe, the URL i.e. is not meant to access remote resources. For remote resources, one might need something like,

I believe. However, I am looking to use a connection pool out of application server, say, commons dbcp or c3p0. Please provide me some more insight.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I am still thinking 'JNDI', it can be backed by DBCP or anything as long as it exposes a DataSource to external clients.

I'm trying to remember how we did something like this ages ago, but I imagine it would be possible to get just the 'JNDI' part of a JEE somewhere.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by David O'Meara:
I am still thinking 'JNDI', it can be backed by DBCP or anything as long as it exposes a DataSource to external clients.

I'm trying to remember how we did something like this ages ago, but I imagine it would be possible to get just the 'JNDI' part of a JEE somewhere.


Exactly. I proposed the thing with JNDI in my mind, now trying to help myself.

Moreover, the URL I have given are meant to be used with JNDI. But I am afraid, that I would need an application server just to use JNDI or might need to write some kind of service - using RMI or something - to expose the resource.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I found this...

http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4072489
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
That looks, quite sound.
Thank you, David. Will try it out.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Really I have no idea, but if it works out then feel free to come back and tell us! It sounds like an interesting exercise
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Sure thing.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

fscontext, that's the one.
Have a read of this
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
It seems, few significant pages are not the part of the preview.

It doesn't show anything like how we get the datasource from a remote machine. I mean the details are missing or I am missing. It looks like that it meant for sharing across different JVMs and Machines, though. Do you have any experience with this?

Or otherwise, we should look into rmi-based thingy. What say you?

Thanks you for the link. Greatly appreciated.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

It turns out I have a similar problem in need of this solution.

We have code running in a Tomcat server, using a server managed DataSource to provide Connections.

Many classes fail when called during testing, since they need to find the InitialContext and cannot do so when testing via JUnit. While we could look at running these tests within the container I am always hesitant about combining test and production code.

The current view is that we use the fscontext in the TestCase super class to initialise the file based JNDI and make Connections available to classes that expect one.

Maybe.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Dropped the idea, it was contradicting the notion, "Separation of Concerns". We replaced it with a DataAccessService objects. Now, the Master - Master/Worker pattern - need not handle connections and related stuff, instead call the service and get the result.

Cheers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Shared DB Connection Pool
 
Similar Threads
Connection Pool
Multi-threading in web services ?
DBCP connection pooling with multiple web-apps
What is the best way to share database connection pool?
DB Connection Pool refresh