Does the "location" datasource offer pooling as well? In the documentation,
I think it only says that the "ejb-location" datasource does. In my apps (no
production apps, mind you) I have always used the ejb-location, even from
the web tier. Works fine. 

Is there any reason for not using it?

/Manne 

-----Original Message-----
From: Jens Stutte [mailto:[EMAIL PROTECTED]]
Sent: 20 June 2001 17:17
To: Orion-Interest
Subject: AW: Newbie - using EJB and databases


Hi all,

the code seems correct, however the "jdbc/MyPooledDS" location name does not
explain, which of the names specified in datasources.xml you should lookup
(this may have dramatic consequences both for performance and integrity).

In datasources.xml, you can specify names for three locations, like:

location="jdbc/BaseDB"
xa-location="jdbc/xa/BaseXADB"
ejb-location="jdbc/BaseEJBDB"

>From within a servlet and/or a JSP page, you normally use the "location".
>From within a session- or BMP-entity-bean, you must use the "ejb-location",
to ensure the proper function of container managed transactions (BTW, this
also works much faster than using the normal "location"). I never used the
"xa-location", i don't know where it may be usefull.

Best regards,

Jens Stutte

> -----Ursprüngliche Nachricht-----
> Von: Johan Fredriksson [mailto:[EMAIL PROTECTED]]
> Gesendet am: Mittwoch, 20. Juni 2001 13:52
> An: Orion-Interest
> Betreff: Re: Newbie - using EJB and databases
> 
> This is how I always do....
> 
> 
> import java.sql.*;
> 
> public class DB {
>  private static javax.sql.DataSource ds = null;
> 
>  //Initieringsblock
>  static {
>   String dbsource = "jdbc/MyPooledDS";
> 
>   try
>   {
>    javax.naming.Context ctx = new javax.naming.InitialContext();
>    if (ctx == null) {
>     System.out.println("No context!");
>    }
>    ds = (javax.sql.DataSource)ctx.lookup(dbsource);
>   }
>   catch(javax.naming.NamingException namExc)
>   {
>    ds = null;
>    namExc.printStackTrace();
>    throw new java.lang.RuntimeException("Failed to get datasource!!");
> 
>   }
>  }
> 
>  public DB()  {}
> 
>  public static java.sql.Connection getConnection() throws
> java.sql.SQLException {
>   return ds.getConnection();
>  }
> 
> 
> }
> 
> 
> then I just call
> 
> Connection conn = DB.getConnection();
> 
> from my apps/beans/whatever
> 
> 
> Johan
> ----- Original Message -----
> From: "kevin1" <[EMAIL PROTECTED]>
> To: "Orion-Interest" <[EMAIL PROTECTED]>
> Sent: Wednesday, June 20, 2001 2:06 AM
> Subject: Newbie - using EJB and databases
> 
> 
> >
> > Hello all,
> > I am still new to the whole EJB thing, but I have a grasp 
> on it.  However,
> > the one thing I am foggy on is how to use a database.  I 
> know that I set
> up the
> > db connection in the data-sources.xml file, but what is the 
> syntax to use
> that
> > in an application?  Where could I find an example of that?
> 
> 

Reply via email to