aspose file tools*
The moose likes JDBC and the fly likes Which one is the best ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Which one is the best ? " Watch "Which one is the best ? " New topic
Author

Which one is the best ?

Sanjeev Charla
Ranch Hand

Joined: Apr 02, 2009
Posts: 90

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

Joined: Apr 14, 2004
Posts: 10336

Is this an interview question?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Sanjeev Charla
Ranch Hand

Joined: Apr 02, 2009
Posts: 90

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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Sep 22, 2010
Posts: 3
Create a connection pool and get and close a connection.
A Santini
Greenhorn

Joined: Sep 22, 2010
Posts: 3
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

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Sep 22, 2010
Posts: 3
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.
 
jQuery in Action, 2nd edition
 
subject: Which one is the best ?