Claude,

There is a good article on 'Connection strategies in EntityBeans' by Prakash
Malani published in Java Report Apr 2001
(http://www.javareport.com/html/from_pages/article.asp?id=799). It is for
BMP EntityBeans, but the ideas in the article is valid for your problem.
Also read Chapter 7.4.1 of the EJB 2.0 spec. Of your proposed solutions I
find it more elegant to save the reference per bean instance, how the first
one turns out will be dependent on how your vendor is distributing the
instances across JVMs.

/ Daniel


>From: Claude <[EMAIL PROTECTED]>
>Reply-To: Claude <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Usage of a DataSource object
>Date: Fri, 21 Sep 2001 03:14:12 -0700
>
>Hi
>
>I have the folowing code in all the business methods of a stateless session
>bean:
>
>initialContext = new InitialContext();
>dataSource = (DataSource)initialContext.lookup
>("java:comp/env/jdbc/AccountDB");
>
>I was thinking of 2 alternatives to optimize the performance:
>
>1) executing this code only once (the first time ever that a business
>method is called, for example) and saving the dataSource reference in a
>static member of some class of my bean.
>
>2) executing this code in ejbCreate() and saving a reference of a
>dataSource object for each bean instance. With this solution, I would save
>a lot less CPU time than with the previous solution, though.
>
>I can't find anything in the EJB spec about it.
>Which solution would you choose?
>Would you try to optimise this at all?
>
>Claude
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff EJB-INTEREST".  For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to