Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which one is the best ?

 
Sanjeev Charla
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In any type of application (web/ desktop) which one is the best ?

1. making and closing the connection with database for each and every use.
or
2. make a connection and use that connection until the end of application.
or
3. whether, it depends upon the data source and/or application.?

please explain,

Thank you.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this an interview question?
 
Sanjeev Charla
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no no,
not like that,
just i want to know, how making and closing a connection will effects the total performance, that's it.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course it will affect performance--opening and closing a connection takes time.

So, since your question was completely generic and provided zero useful information, the answer is "it depends". Sure sounds like an interview question to me, since you're not asking anything specific.
 
A Santini
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a connection pool and get and close a connection.
 
A Santini
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to resurrect an old thread. I'm new here and the sort is all screwed up. Should be sorted by date..or at least thats what Im used to.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't worry - this isn't an old thread

I would say that connection pools are probably overkill for single user desktop applications. You are only ever likely to need one connection there.
 
A Santini
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah I was looking at the wrong date. Will take me a little while to get used to this place.

I thought the question was for web / desktop in that case I thought it meant for web and/or desktop.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic