Two questions:

What is the singleton?

Where it is possible to receive such class ?

----- Original Message -----
From: "Jon Crater" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 26, 2001 5:17 PM
Subject: RE: Database connection pool scope


> i use a connection pool in tomcat 3.2.1.  i have a servlet,
> ConnectionBroker.java, which, in its init() method checks for the
existence
> of the connection pool.  if the connection pool is null, it creates an
> instance of it and binds it to the servlet context.  then other classes
can
> call this class' static getConnection() and releaseConnection() methods
> without having to worry about whether they extend HttpServlet.  the init
> method looks like this:
>
>     public void init()
>     {
>         ServletContext ctx = getServletContext();
>         jdbcPool = (ConnectionPool)ctx.getAttribute("jdbcPool");
>
>         if (jdbcPool == null)
>         {
>             try
>             {
>                 jdbcPool = ConnectionPool.getInstance();
>                 ctx.setAttribute("jdbcPool", jdbcPool);
>             }
>             catch (SQLException sqle)
>             {
>                 debug("SQLException caught: " + sqle.getMessage());
>             }
>         }
>     }
>
> the getConnection() method looks like this:
>
>     public static Connection getConnection()
>         throws SQLException
>     {
>         return jdbcPool.getConnection();
>     }
>
> i then have a singleton ConnectionPool class which creates and manages
jdbc
> connections.
>
> -jc
>
>
> ----Original Message Follows----
> From: Randy Layman <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: RE: Database connection pool scope
> Date: Mon, 26 Feb 2001 07:58:53 -0500
>
>
> First of all, there are several connection pools avaiable, so you
> might want to look at those before you decide that re-inventing the wheel
is
> a good thing.
>
> Second, most connection pools work by using static classes.  Your
> code would look something like:
>
> Connection conn = ConnectionPool.getConnection();
>
> and the ConnectionPool would look something like:
>
> public static Connection getConnection()
>
>
> Randy
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, February 26, 2001 5:17 AM
> To: [EMAIL PROTECTED]
> Subject: Database connection pool scope
>
>
> Hello everybody,
>
> I am pretty new to Tomcat, but previously developed applications for other
> Java application servers (mostly Bea Weblogic). We want to set up a
> database connection pool to enhance performance, but we are making
database
> connections using our class libraries; not directly from servlets /
JSPs...
> To use a pool inside a JSP I would simply create an application object or
a
> JavaBean and use it. But inside a class; I cannot use Tomcat's application
> scope. In Weblogic, there is a special "workspace" class, which
> instantiates with the server startup and is available to other classes in
> the application (this is very similar to the application object in JSPs -
> but you can use it everywhere). Is there a counterpart in Tomcat? If not,
> how can I implement a connection pool which is available to the business
> classes that I wrote.
>
> Thanks in advance.
> Selcuk Ayguney
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to