File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bad decision to open connection inside PostConstruct and close connection inside PreDestroy?

 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I've read in EJB books, it suggests to open connection inside PostConstruct and close connection inside PreDestroy.

This is totally wrong decision to implement. Since Stateless Beans are pooled by container, it will open multiple connections and you never know when SSB will be destroyed. By the time it will be destroyed, you will ran out of connections.

In only one scenario it would make perfect sense to use above approach when you balance the numbers between number of pooled SSB's and the number of DB connections that can be opened.

Let me know your thoughts if you have faced same scenario.
 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any thoughts on this? I stumbled on this issue again, so came across on my own thread.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic