tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Valeriy Molyakov" <val...@kompan.com.ua>
Subject Re: Database connection pool scope
Date Wed, 28 Feb 2001 07:46:23 GMT
I have few questions :

1. What the implementations for connection caches are availablis ?

2. In what advantages of such products before vendors drivers that is
supporting JDBC API 2.0 (ConnectionPoolDataSource)

3. Can I call my method ( not doPost(),doGet(),service() ) from other
servlet ? This method - multithreading ?

----- Original Message -----
From: "Jon Crater" <jmcrater@hotmail.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Monday, February 26, 2001 6:35 PM
Subject: Re: Database connection pool scope


> the singleton is just a concrete java class that ensures only one instance
> can ever be instantiated.  i ensure this via this method:
>
>   public static synchronized ConnectionPool getInstance()
>     throws SQLException
>   {
>       if (instance == null)
>       {
>           instance = new ConnectionPool(driver,url,username,password,
>                                       initialConnections,maxConnections,
>                                         waitIfBusy);
>       }
>       return instance;
>   }
>
> this class is no different than any other class.  the important part of
> making the connection pool available to the rest of your application is
> storing the reference to the pool in the servlet context.  once you've
done
> this, and assuming your connectionbroker class is a servlet with access to
> the servlet context containing the connection pool reference, you can call
> getConnection() and releaseConnection() on the servlet class, which in
turn
> gets and returns connections from/to the connection pool.
>
> ----Original Message Follows----
> From: "Valeriy Molyakov" <valera@kompan.com.ua>
> Reply-To: tomcat-user@jakarta.apache.org
> To: <tomcat-user@jakarta.apache.org>
> Subject: Re: Database connection pool scope
> Date: Mon, 26 Feb 2001 18:12:15 +0200
>
> Two questions:
>
> What is the singleton?
>
> Where it is possible to receive such class ?
>
> ----- Original Message -----
> From: "Jon Crater" <jmcrater@hotmail.com>
> To: <tomcat-user@jakarta.apache.org>
> 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 <randy.layman@aswethink.com>
>  > Reply-To: tomcat-user@jakarta.apache.org
>  > To: tomcat-user@jakarta.apache.org
>  > 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: sayguney@demirbank.com.tr [mailto:sayguney@demirbank.com.tr]
>  > Sent: Monday, February 26, 2001 5:17 AM
>  > To: tomcat-user@jakarta.apache.org
>  > 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: tomcat-user-unsubscribe@jakarta.apache.org
>  > For additional commands, email: tomcat-user-help@jakarta.apache.org
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>  > For additional commands, email: tomcat-user-help@jakarta.apache.org
>  >
>  >
>  > _________________________________________________________________
>  > Get your FREE download of MSN Explorer at http://explorer.msn.com
>  >
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>  > For additional commands, email: tomcat-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org


Mime
View raw message