Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rd Dari
Ranch Hand
Posts: 212
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rd Dari
Ranch Hand
Posts: 212
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 212
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would only be a problem if memory was more constrained than time. Memory is cheap so this isn't often the case.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic