CHEBURASHKA
CHEBURASHKA

Reputation: 1713

Should I create a new DB connection for each query ?

In my servlet , i have a .jsp page that has a form and a submit button

Ones a user clicks submit a new connection to the teradata database is created and and the result of the query is posted for the user to view it .

I read many questions about servlet to databse connection on Stackoverflow and in BalusC website

Is it the right way ? Should I create a new connection to the database every time a user click on the submit button . Or should I use some kind of DAO described by BalusC . Or is it good only for authentication ? I am not sure that my currect approach is correct

Upvotes: 0

Views: 256

Answers (2)

Ove Sundberg
Ove Sundberg

Reputation: 333

Use a connection pool. Personally, I like BoneCP. 3CPO is more or less industry standard though.

Upvotes: 2

Jigar Joshi
Jigar Joshi

Reputation: 240976

You should manage database connection pool google for c3po, creating new connection is costly operation

Upvotes: 4

Related Questions