Also, you could make your connection pool class a singleton class. Suppose
you have a class ConnectionPool with a method getConnection() that returns
a java.sql.connection. You could make a singleton class like this:
class SingletonConnectionPool {
private static SingletonConnectionPool m_conPool = null;
public static getInstance() {
if (m_conPool == null)
m_conPool = new SingletonConnectionPool();
return m_conPool();
}
private SingletonConnectionPool(...);
}
That way, every time you needed access to a connection pool, you would call
SingletonConnectionPool.getInstance(), and still be assured that only 1
connection pool ever exists. If you need a start on a connection pool
class, go to http://www.servlets.com/jsp/examples/index.html and download
jservlet.zip, which has a basic ConnectionPool class.
Alex Devine
Ted Fritsch
<tfritsch@BIGFOOT To: [EMAIL PROTECTED]
.COM> cc:
Sent by: A Subject: Re: beans accessing database
pool
mailing list
about Java Server
Pages
specification and
reference
<JSP-INTEREST@JAV
A.SUN.COM>
02/24/00 07:11 AM
Please respond to
Ted Fritsch
You will want to have the connection pool created when you start your
server - some
servers like BEA Weblogic also have built-in connection pooling, so if you
configure it properly the connection pool will be instantiated when you
start the
server. Then, from your bean you just get a connection from the
connection pool,
rathar than from the db. WHen you are finished with the connection, you
then
return it to the pool and it can be used by another request.
Hope this helps,
Ted
Jeff Behl wrote:
> What's the best way to do this on a bean that only has request scope? it
> doesn't make much sense to have a database pool instantiated every time
> the bean is. Without goign to an EJB model, is placing a database pool
in
> the bean via a scriplet a viable option?
>
> basically, I want to use the same bean on a number of product web pages
to
> display product specific information. Current plan is to have a
> setProperty method that sets the ProductID (primary key) on each page
> which allows the bean to grab the product information. If anyone has a
> better way to do this, I'd love to hear about it.
>
> thanks
>
> --
> Jeff Behl [EMAIL PROTECTED]
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
--
---------------------------------
Ted L. Fritsch
The Revere Group
Phone: (847) 790-9800 x4103
Email: [EMAIL PROTECTED]
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html