Hi Joe,

I posted a similiar question earlier. I got an answer from Philippe:

-----------cut--------------------
To get a DataSource in your CMP  EntityBean  you can do:

try {
        initialContext = new InitialContext();
        dataSource
=(DataSource)initialContext.lookup("java:comp/env/jdbc/MyDs");
            } catch (Exception e) {
     ...
     ...

With in your XML DD
 <resource-ref>
        <res-ref-name>jdbc/MyDs</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
 </resource-ref>

-----------cut--------------------

I hope this helps!
        simon

Joe Gittings wrote:
> 
> Hi all,
> 
> I'd like to retrieve the javax.sql.DataSource bound to a CMP entity bean,
> from within an implementation method of that bean. In Jonas 1.6.1 this
> could easily be done with
> 
>          String sDataSourceName = env.getProperty("datasource.name");
>          DataSource ds =
> (DataSource)initialContext.lookup(sDataSourceName);
> 
> In Jonas 2.0 I cannot see an easy way to do this - does anyone know of a
> way? Apologies if this is a dumb question!
> 
> Joe
> 
> =====================================================================
> Joe Gittings, Royal Botanic Gardens, Kew
> Hanover House, Kew, Richmond, Surrey TW9 3AB
> 
> [EMAIL PROTECTED]
> +44 20 8332 5712
> fax: +44 20 8332 5736
> 
> ----
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body of the message "unsubscribe jonas-users".
> For general help, send email to [EMAIL PROTECTED] and
> include in the body of the message "help".
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to