Title: RE: [JBoss-user] How do I obtain a connection from the DefaultDS from my session bean

Sorry about the formatting on that last post. Try again...

If you click on the link "service=LocalTxDS,name=hsqldbDS" you should see a JndiName entry with the value "DefaultDS"

    -----Original Message-----
    From:   Allan Kamau [SMTP:[EMAIL PROTECTED]]
    Sent:   Thursday, July 11, 2002 10:13 AM
    To:     [EMAIL PROTECTED]
    Subject:        RE: [JBoss-user] How do I obtain a connection from the DefaultDS  from my session bean

    Thanks Jamie Burns, it works.
    I am wondering how come I don't find the "DefaultDS"
    entry running on my JBoss-3.0.0 accessing the resource
    at "http://localhost:8082/" I only see the "hsqldbDS"
    entry. When I try use the "hsqldbDS" in place of
    "DefaultDS" in the code sample below, it doesn't work.

    Allan.


    --- "Burns, Jamie" <[EMAIL PROTECTED]>
    wrote:
    > I think your code should be
    >
    >       Context jndiCntx=getInitialContext();
    >       DataSource ds =
    > (DataSource)jndiCntx.lookup("java:/DefaultDS");
    >
    >       return ds.getConnection();
    >
    > > -----Original Message-----
    > > From:       Allan Kamau [SMTP:[EMAIL PROTECTED]]
    > > Sent:       Thursday, July 11, 2002 9:02 AM
    > > To: [EMAIL PROTECTED]
    > > Subject:    [JBoss-user] How do I obtain a connection
    > from the DefaultDS
    > > from my session bean
    > >
    > > I am trying to obtain a connection from the
    > DefaultDS,
    > > but I get the error "DefaultDS not Bound".
    > > Below is the code I use to try a bind to the
    > > DefaultDS.
    > >
    > > <code>
    > >     private Connection getConnection()throws
    > SQLException
    > >     {
    > >             try
    > >             {
    > >
    > >                     Context jndiCntx=getInitialContext();
    > >                     Object ref=jndiCntx.lookup("DefaultDS");
    > >                     DataSource
    > >
    >
    ds=(DataSource)javax.rmi.PortableRemoteObject.narrow(ref,DataSource.class)
    > > ;
    > >
    > >
    > >
    > >                     return ds.getConnection();
    > >             }
    > >             catch(NamingException ne)
    > >             {
    > >                     throw new EJBException(ne);
    > >             }
    > >     }
    > >     public static Context getInitialContext()
    > >         throws javax.naming.NamingException {
    > >
    > >             java.util.Properties env=new
    > java.util.Properties();
    > >    
    > >
    >
    env.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingCo
    > > ntextFactory");
    > >    
    > >
    >
    env.setProperty("java.naming.provider.url","localhost:1099");
    > >    
    > >
    >
    env.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.i
    > > nterfaces");
    > >             InitialContext initialContext = new
    > > InitialContext(env);
    > >             return initialContext;
    > >     }
    > > </code>
    > > Thanks.
    > >
    > >
    > >
    > > __________________________________________________
    > > Do You Yahoo!?
    > > Sign up for SBC Yahoo! Dial - First Month Free
    > > http://sbc.yahoo.com
    > >
    > >
    > >
    >
    -------------------------------------------------------
    > > This sf.net email is sponsored by:ThinkGeek
    > > PC Mods, Computing goodies, cases & more
    > > http://thinkgeek.com/sf
    > > _______________________________________________
    > > JBoss-user mailing list
    > > [EMAIL PROTECTED]
    > >
    >
    https://lists.sourceforge.net/lists/listinfo/jboss-user
    >
    >
    ********************************************************************************
    >   This electronic mail system is used for
    > information purposes and is
    >   not intended to form any legal contract or binding
    > agreement.
    >   The content is confidential and may be legally
    > privileged. Access
    >   by anyone other than the addressee(s) is
    > unauthorised and any
    >   disclosure, copying, distribution or any other
    > action taken in
    >   reliance on it is prohibited and maybe unlawful
    >
    >   All incoming and outgoing e-mail communications
    > and attachments
    >   are scanned automatically by software designed to
    > detect and remove
    >   any material containing viruses or other
    > unauthorised content.  While
    >   we undertake best endeavours to ensure that this
    > content checking
    >   software is up to date, recipients should take
    > steps to assure themselves
    >   that e-mails received are secure.
    >
    ********************************************************************************
    >


    __________________________________________________
    Do You Yahoo!?
    Sign up for SBC Yahoo! Dial - First Month Free
    http://sbc.yahoo.com


    -------------------------------------------------------
    This sf.net email is sponsored by:ThinkGeek
    PC Mods, Computing goodies, cases & more
    http://thinkgeek.com/sf
    _______________________________________________
    JBoss-user mailing list
    [EMAIL PROTECTED]
    https://lists.sourceforge.net/lists/listinfo/jboss-user

********************************************************************************
  This electronic mail system is used for information purposes and is
  not intended to form any legal contract or binding agreement.
  The content is confidential and may be legally privileged. Access
  by anyone other than the addressee(s) is unauthorised and any
  disclosure, copying, distribution or any other action taken in
  reliance on it is prohibited and maybe unlawful

  All incoming and outgoing e-mail communications and attachments
  are scanned automatically by software designed to detect and remove
  any material containing viruses or other unauthorised content.  While
  we undertake best endeavours to ensure that this content checking
  software is up to date, recipients should take steps to assure themselves
  that e-mails received are secure.
********************************************************************************

Reply via email to