*
The moose likes JDBC and the fly likes Pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Pooling" Watch "Pooling" New topic
Author

Pooling

sinasi susam
Ranch Hand

Joined: Jul 15, 2005
Posts: 67
I want to develop a web allpication .

What are the benefits of pooling?

what happens if we dont use a pooling in a web based application?

if a pooling is a logic of one connection for one user
what happens if two user uses same connection instance?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41582
    
  54
The benefit is avoiding the overhead of opening connections, which are network operations nad potentially time- and resource-consuming.

If you don't use them, you don't get that benefit. And since all serious JDBC drivers come with pooling built-in these days, there's very little work required in using them. Your logic will need to ensure that you return connections to the pool once you're done with them, of course.

Pooling does not mean "one user - one connection", but potentially "many users - one connection". Connections would not be used simultaneously by two users. One user would get a connection from the pool, use it, and then return it to the pool. It would be a bad thing if two users would use the same connection at the same time, possibly even within transactions.


Ping & DNS - my free Android networking tools app
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by sinasi susam:
what happens if two user uses same connection instance?


Nothing, all would be fine. Unless they use it simultaneously.
sinasi susam
Ranch Hand

Joined: Jul 15, 2005
Posts: 67
I can realize that it will be problem when rolling back with the method of Connection class.

if our jobs were not transactional so there will not be problem right?

How many statements can we create from a connection?
Can we create how much we want?Is it up to us or its limited?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41582
    
  54
You can create as many statements through a connection as you like, though not simultaneously, only in succession. And it doesn't matter if they're made by different users, as long as they're not transactional.
 
wood burning stoves
 
subject: Pooling