• Post Reply Bookmark Topic Watch Topic
  • New Topic

DB connection on init

 
Inesh Hettiarachchi
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i want to know if i use connection pooling where should i establish my db connection is it in init or service
if i put in the init since the init is executed onely onece will give me any problems when concurrent uses login to the app or if i have 10 servlets will there any problem in the connection pool with 5 connection avalable.

it would be a big help if anyone can give me any thing
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't want to get your connection from the init method.
The point of a connection pool is to get a connection when you need it and return it to the pool as soon as your done with it.
 
Mark Spritzler
ranger
Sheriff
Posts: 17290
9
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I'd avoid getting it from the pool anywhere in the Servlet code itself. You business logic and data access code should be in Plain Old Java Objects that are called from the Servlet. This way that business logic and data access can be reused by other types of clients.

Mark
 
Inesh Hettiarachchi
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot it did help me a lot
 
stan ioffe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which app server are u using?
If you're using something like WebSphere, all you need to do is configure your JDBC connection and your connection pooling is going to be handled by the app server ... just a thought
-stan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!