Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes Is this possible to create more than one connection in a java application?define loss and benefit. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Is this possible to create more than one connection in a java application?define loss and benefit." Watch "Is this possible to create more than one connection in a java application?define loss and benefit." New topic
Author

Is this possible to create more than one connection in a java application?define loss and benefit.

Rd Dari
Ranch Hand

Joined: Feb 22, 2010
Posts: 206

Hi ,
I have a question that Is it possible to create more than one database connection in one application if it is then what are loss and benefit of it?


And in my opinion it is possible but there is no benefit instead it will allocate more memory.I want to exact answer.

Thanks!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Yes, very possible and frequently done (have a search for "Connection Pool"). You would use more then one connection if your application supports more than one user.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rd Dari
Ranch Hand

Joined: Feb 22, 2010
Posts: 206

OK but in which condition I have more than one user in one application. I think it can be from a single connection.....

please explain it in detail.

Thanks in advance!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

When the application is a server based application.

Even without multiple users, you may want to have background processes using the database asynchronously. Turn the question on its head: why do you think it is a good thing to restrict an application to one connection?
Rd Dari
Ranch Hand

Joined: Feb 22, 2010
Posts: 206

OK right, but I's thinking that is wasting of memory to using connection more than one time .

Thanks! for your opinion and good answer.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

That would only be a problem if memory was more constrained than time. Memory is cheap so this isn't often the case.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is this possible to create more than one connection in a java application?define loss and benefit.
 
Similar Threads
Accesing ResultSet
DB connection in a servlet question
Passing the session variable from one HTML to JSP through Servlets?
Connecting to more than one database in a connection pool
JDBC Error