• Post Reply Bookmark Topic Watch Topic
  • New Topic

Connection Pool & JSP  RSS feed

 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Would it be good to pass the Connection from ConnectionPool into the JSP and using the same Connection while referencing any bean from that JSP, and returning the Connection in the finally block

OR

Passing the Connection in each bean & return the connection back to the pool in the bean itself, i.e I instantiate the bean by calling the contructor with the entire "ConnectionPool" as the parameter & then use its method by getting a connection & returning as soon as I am done with the logic.

Which one is a better approach....??

TIA
MB
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have to choose between the two, then the first one is better. However, consider using a separate model class which contains the data and pass that to your bean's constructor.

Jules
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!