how did you map a datasource in to the jndi namespace?  i've been trying to
accomplish this in jrun for a while...  i can see no way to do it from the
jrun docs.

| chris wilson || web dev ||| www.wondergeek.com || |

> -----Original Message-----
> From: Marcelo Bellezo [mailto:[EMAIL PROTECTED]]
> Sent: Monday, October 16, 2000 12:29 PM
> To: JRun-Talk
> Subject: Re: Aquiring a JDBC connection resource from within an EJB
>
>
>
> --------------BA11068EFEA16C57769C01B7
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> Hi Jay,
>
> no, you can use JNDI, I'm using the following:
>
>   /**
>    * Gets current connection to the connection pool.
>    *
>    * @return                  Connection
>    * @exception               javax.ejb.EJBException
>    *                          if there is a communications or
> systems failure
>    */
>     private Connection getConnection()
>         throws SQLException{
>         InitialContext initCtx = null;
>         DataSource ds = null;
>         try {
>             initCtx = new InitialContext();
>             ds =
> (javax.sql.DataSource)initCtx.lookup("java:comp/env/jdbc/dsnname");
>             this.conn = ds.getConnection();
>
>         } catch(NamingException ne) {
>             System.out.println("UNABLE to get a connection from
> dsnname Pool!");
>             System.out.println("Please make sure that you have
> setup the connection pool
> properly");
>             System.out.println(ne);
>         } finally {
>             try {
>                 if(initCtx != null) initCtx.close();
>             } catch(NamingException ne) {
>                 System.out.println("Error closing context: " + ne);
>                 System.out.println(ne);
>             }
>         }
>         return this.conn;
>     }
>
> Regard's
>
> Marcelo Bellezo
>
> Jay Walters wrote:
>
> > >From the docs it looks like the only valid way to do this
> inside JRun is
> > ResourceManager.getConnection, and that I cannot use a JNDI
> lookup?  Is this
> > true?
> >
> > Cheers
> >
> ------------------------------------------------------------------
> ------------
> > Archives: http://www.egroups.com/group/jrun-interest/
> > Unsubscribe:
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
> > or send a message to [EMAIL PROTECTED] with
> 'unsubscribe' in the body.
>
> --------------BA11068EFEA16C57769C01B7
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> <html>
> Hi Jay,
> <p>no, you can use JNDI, I'm using the following:
> <p>&nbsp; /**
> <br>&nbsp;&nbsp; * Gets current connection to the connection pool.
> <br>&nbsp;&nbsp; *
> <br>&nbsp;&nbsp; *
> @return&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
> ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> Connection
> <br>&nbsp;&nbsp; *
> @exception&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
> bsp;&nbsp;&nbsp;&nbsp;&nbsp;
> javax.ejb.EJBException
> <br>&nbsp;&nbsp;
> *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
> ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
> ;&nbsp;&nbsp;&nbsp;
> if there is a communications or systems failure
> <br>&nbsp;&nbsp; */
> <br>&nbsp;&nbsp;&nbsp; private Connection getConnection()
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throws SQLException{
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitialContext initCtx =
> null;
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataSource ds = null;
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> initCtx = new InitialContext();
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> ds = (javax.sql.DataSource)initCtx.lookup("java:comp/env/jdbc/dsnname");
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> this.conn = ds.getConnection();
> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch(NamingException ne)
> {
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> System.out.println("UNABLE to get a connection from dsnname Pool!");
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> System.out.println("Please make sure that you have setup the connection
> pool properly");
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> System.out.println(ne);
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } finally {
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> try {
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
> bsp;&nbsp;&nbsp;&nbsp;&nbsp;
> if(initCtx != null) initCtx.close();
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> } catch(NamingException ne) {
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
> bsp;&nbsp;&nbsp;&nbsp;&nbsp;
> System.out.println("Error closing context: " + ne);
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
> bsp;&nbsp;&nbsp;&nbsp;&nbsp;
> System.out.println(ne);
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> }
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.conn;
> <br>&nbsp;&nbsp;&nbsp; }
> <p>Regard's
> <p>Marcelo Bellezo
> <p>Jay Walters wrote:
> <blockquote TYPE=CITE>>From the docs it looks like the only valid way to
> do this inside JRun is
> <br>ResourceManager.getConnection, and that I cannot use a JNDI
> lookup?&nbsp;
> Is this
> <br>true?
> <p>Cheers
> <br>--------------------------------------------------------------
> ----------------
> <br>Archives: <a
> href="http://www.egroups.com/group/jrun-interest/">http://www.egro
> ups.com/group/jrun-interest/</a>
> <br>Unsubscribe: <a
> href="http://www.houseoffusion.com/index.cfm?sidebar=lists&body=li
> sts/jrun_talk">http://www.houseoffusion.com/index.cfm?sidebar=list
> s&amp;body=lists/jrun_talk</a>
> <br>or send a message to [EMAIL PROTECTED] with
> 'unsubscribe'
> in the body.</blockquote>
> </html>
>
> --------------BA11068EFEA16C57769C01B7--
>
> ------------------------------------------------------------------
> ------------
> Archives: http://www.egroups.com/group/jrun-interest/
> Unsubscribe:
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
or send a message to [EMAIL PROTECTED] with 'unsubscribe'
in the body.

------------------------------------------------------------------------------
Archives: http://www.egroups.com/group/jrun-interest/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the 
body.

Reply via email to