You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by David Moran <dm...@nc.rr.com> on 2004/02/10 05:23:01 UTC

where to create database connections?

I found the post below in the archive and the following in the user
guide. So are there any guidelines as to when to create database
connections using the global object verses subclassing the
ApplicationServlet?

The most typical use of the Global object is to interface to J2EE
resources such as EJB home and remote interfaces or JDBC data sources.
The shared Global object can cache home and remote interfaces that are
efficiently shared by all engine instances. 

On Sun, 2004-01-18 at 22:38, Howard M. Lewis Ship wrote:
> Sounds like a problem with your database connection pool.
> 
> You might want to subclass ApplicationServlet to hook it's init() method, and create the connection
> pool there. 
> 
> Alternately, you could subclass BaseEngine, make it a HttpSessionBindingListener and figure out when
> the session ends (or user logs out).
> 
> With servlet Api 2.3+, you have more events ... you can create objects that live in the
> ServletContext as attributes ... store the connection pool there and get a notification as the old
> version of the app shuts down to clean it up and close it out.
> 
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Tapestry: Java Web Components 
> http://jakarta.apache.org/tapestry/
> http://javatapestry.blogspot.com
> 
> > -----Original Message-----
> > From: Glen Stampoultzis [mailto:gstamp@iinet.net.au] 
> > Sent: Sunday, January 18, 2004 8:20 PM
> > To: tapestry-user@jakarta.apache.org
> > Subject: How to reload gracefully
> > 
> > 
> > 
> > I haven't been getting many hits on my questions lately but 
> > I'll try anyway.
> > 
> > I have reloading turned on in tapestry.  I'm using HSQLDB 
> > which opens up 
> > the database in-place.
> > 
> > Currently when the webapp reloads I get an error because 
> > HSQLDB is still 
> > holding the database open.  What I want to know is how to detect the 
> > tapestry servlet is being reloaded and close the database safely.
> > 
> > Regards,
> > 
> > 
> > Glen Stampoultzis
> > gstamp@iinet.net.au
> > http://members.iinet.net.au/~gstamp/glen/
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: where to create database connections?

Posted by Harish Krishnaswamy <hk...@comcast.net>.
I tend to stay away from the core framework classes as much as possible. 
I prefer to use the hooks provided, Global and application extensions 
are a couple of those. But if you need to be informed of the servlet 
lifecycle events, you may have to extend the engine or servlet as 
suggested below. If you are looking for plain JDBC connections, a 
connection pool bound to JNDI is probably the best bet. Couple options: 
DBCP, C3P0.

-Harish

David Moran wrote:

>I found the post below in the archive and the following in the user
>guide. So are there any guidelines as to when to create database
>connections using the global object verses subclassing the
>ApplicationServlet?
>
>The most typical use of the Global object is to interface to J2EE
>resources such as EJB home and remote interfaces or JDBC data sources.
>The shared Global object can cache home and remote interfaces that are
>efficiently shared by all engine instances. 
>
>On Sun, 2004-01-18 at 22:38, Howard M. Lewis Ship wrote:
>  
>
>>Sounds like a problem with your database connection pool.
>>
>>You might want to subclass ApplicationServlet to hook it's init() method, and create the connection
>>pool there. 
>>
>>Alternately, you could subclass BaseEngine, make it a HttpSessionBindingListener and figure out when
>>the session ends (or user logs out).
>>
>>With servlet Api 2.3+, you have more events ... you can create objects that live in the
>>ServletContext as attributes ... store the connection pool there and get a notification as the old
>>version of the app shuts down to clean it up and close it out.
>>
>>--
>>Howard M. Lewis Ship
>>Independent J2EE / Open-Source Java Consultant
>>Creator, Tapestry: Java Web Components 
>>http://jakarta.apache.org/tapestry/
>>http://javatapestry.blogspot.com
>>
>>    
>>
>>>-----Original Message-----
>>>From: Glen Stampoultzis [mailto:gstamp@iinet.net.au] 
>>>Sent: Sunday, January 18, 2004 8:20 PM
>>>To: tapestry-user@jakarta.apache.org
>>>Subject: How to reload gracefully
>>>
>>>
>>>
>>>I haven't been getting many hits on my questions lately but 
>>>I'll try anyway.
>>>
>>>I have reloading turned on in tapestry.  I'm using HSQLDB 
>>>which opens up 
>>>the database in-place.
>>>
>>>Currently when the webapp reloads I get an error because 
>>>HSQLDB is still 
>>>holding the database open.  What I want to know is how to detect the 
>>>tapestry servlet is being reloaded and close the database safely.
>>>
>>>Regards,
>>>
>>>
>>>Glen Stampoultzis
>>>gstamp@iinet.net.au
>>>http://members.iinet.net.au/~gstamp/glen/
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org