RE: Struts , hibernate, and DBCP

2005-03-30 Thread David G. Friedman
Brian,

How do I put this... You don't go crazy with Hibernate until you're
comfortable with it.  Feel free to start with implementing a few actions
which do something like this to obtain a Session from within your action:

// assuming you used the hibernate example listener at:
// http://www.hibernate.org/133.html
// This is from memory so I might be slightly off on
// the method calls since I'm using DAO objects to hide
// the implementation from myself
// DAO examples were posted today such as:
// http://daoexamples.sourceforge.net/xref/index.html
//
Session sess = HibernateListener.sessionFactory(request);
try {
// open your transaction
Transaction tx = sess.beginTransaction();
// Perform your questy
// etc.
} catch ( HibernateException he ){
sess.rollback(); // or whatever
} finally {
// etc.
}
// and so forth


Once you are comfortable with that, THEN you should look into more
complicated solutions such as:

A) Using a threalocal
OR
B) Having a Hibernate Session object get created and remove automatically
when the Server creates a session to store objects for you user.  The
methods in that listener class which you would have to implement are
sessionCreated(..) and sessionDestroyed(..).

I don't use ThreadLocal and I get along fine.  I guess that comes from me
being a self-taught hack who really doesn't have a handle on the ThreadLocal
practice. :)

Remember, you should take your time to get used to it before you jump into
the added, but useful, complications of caches, proxying, ThreadLocals, etc.

Regards,
David

-Original Message-
From: Brian McGovern [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 30, 2005 8:53 AM
To: Struts Users Mailing List
Subject: RE: Struts , hibernate, and DBCP


David , OK I got this working.  It creates the pool on startup.  But the
question now becomes how to get a session from the factory.

This listener provides a open(HttpServletRequest) method, but no close
method.  I intend to wrap my data access objects in a separate layer and
would like to avoid passing the current HttpServletRequest to the data
layer.  I'm probably just missing something obvious here, sorry.

Hibernate recommends implementing a utility class that uses ThreadLocal and
provides open and close methods for the current session.  I've created
called this object's currentSession  method from a startup Servlet which
gets my pool to be created on app server startup.  I'm guessing this is a
sloppier approach than implementing the Listener right?

Thanks
-B



-Original Message-
From: David G. Friedman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 6:37 PM
To: Struts Users Mailing List
Subject: RE: Struts , hibernate, and DBCP


Brian,

If you use a Tomcat resource reference to initialize your DB pool, be
careful where you put it: the location you place that init reference makes
the difference between YOUR webapp using the hibernate pool and ANY webapp
being able to use your hibernate pool.

Now, since someone posted about a Servlet Context Listener starting up
Hibernate for you, what is wrong with the one given on the hibernate site
under the page title "Tomcat Event listener for Hibernate" at the URL
http://www.hibernate.org/133.html ?

The example code shows how to have the hibernate configuration read.  You
can easily put pool information in your hibernate.cfg.xml file so Hibernate
starts the DB Pool for you.  (I do that)  Additionally, it lists how, should
you need it, to have a DB Pool instance automatically given out when a
session object is created and how to remove it when a session is ended.

Lastly, if you use C3P0, BE VERY CAREFUL if you are using version 0.8.3 of
C3P0 - there is no proper DB Pool shutdown code in Hibernate if the pool is
of that type (I last checked Hibernate 2.1.6's pool shutdown code).
Proxool, EHCache, and various other pool software have code in the db class
shutdown method in as far as I know.  (I had to research this when I had a
memory issue and kept restarting my webapp yet memory usage kept rising and
I kept seeing new DB pools each webapp restart.)

Regards,
David

-Original Message-
From: Brian McGovern [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 1:41 PM
To: Struts Users Mailing List
Subject: Struts , hibernate, and DBCP


Im using struts, hibernate and dbcp connection pooling.  Everything works
fine but regarding my connection pool.  It gets intantiated on the first
time I request a connection from the DBCP pool.  I want it to create the
pool when tomcat starts.  I think i can do this with struts, but im not sure
how.  If using struts config for htis is not the answer i;d still like to
know what is.

-thanks

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



RE: Struts , hibernate, and DBCP

2005-03-30 Thread Brian McGovern
David , OK I got this working.  It creates the pool on startup.  But the 
question now becomes how to get a session from the factory. 

This listener provides a open(HttpServletRequest) method, but no close method.  
I intend to wrap my data access objects in a separate layer and would like to 
avoid passing the current HttpServletRequest to the data layer.  I'm probably 
just missing something obvious here, sorry.

Hibernate recommends implementing a utility class that uses ThreadLocal and 
provides open and close methods for the current session.  I've created called 
this object's currentSession  method from a startup Servlet which gets my pool 
to be created on app server startup.  I'm guessing this is a sloppier approach 
than implementing the Listener right?

Thanks
-B



-Original Message-
From: David G. Friedman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 6:37 PM
To: Struts Users Mailing List
Subject: RE: Struts , hibernate, and DBCP


Brian,

If you use a Tomcat resource reference to initialize your DB pool, be
careful where you put it: the location you place that init reference makes
the difference between YOUR webapp using the hibernate pool and ANY webapp
being able to use your hibernate pool.

Now, since someone posted about a Servlet Context Listener starting up
Hibernate for you, what is wrong with the one given on the hibernate site
under the page title "Tomcat Event listener for Hibernate" at the URL
http://www.hibernate.org/133.html ?

The example code shows how to have the hibernate configuration read.  You
can easily put pool information in your hibernate.cfg.xml file so Hibernate
starts the DB Pool for you.  (I do that)  Additionally, it lists how, should
you need it, to have a DB Pool instance automatically given out when a
session object is created and how to remove it when a session is ended.

Lastly, if you use C3P0, BE VERY CAREFUL if you are using version 0.8.3 of
C3P0 - there is no proper DB Pool shutdown code in Hibernate if the pool is
of that type (I last checked Hibernate 2.1.6's pool shutdown code).
Proxool, EHCache, and various other pool software have code in the db class
shutdown method in as far as I know.  (I had to research this when I had a
memory issue and kept restarting my webapp yet memory usage kept rising and
I kept seeing new DB pools each webapp restart.)

Regards,
David

-Original Message-
From: Brian McGovern [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 1:41 PM
To: Struts Users Mailing List
Subject: Struts , hibernate, and DBCP


Im using struts, hibernate and dbcp connection pooling.  Everything works
fine but regarding my connection pool.  It gets intantiated on the first
time I request a connection from the DBCP pool.  I want it to create the
pool when tomcat starts.  I think i can do this with struts, but im not sure
how.  If using struts config for htis is not the answer i;d still like to
know what is.

-thanks

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


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


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



RE: Struts , hibernate, and DBCP

2005-03-29 Thread Brian McGovern
Great tips.  Exactly what I was lookin for.  Thanks David.

-Original Message-
From: David G. Friedman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 6:37 PM
To: Struts Users Mailing List
Subject: RE: Struts , hibernate, and DBCP


Brian,

If you use a Tomcat resource reference to initialize your DB pool, be
careful where you put it: the location you place that init reference makes
the difference between YOUR webapp using the hibernate pool and ANY webapp
being able to use your hibernate pool.

Now, since someone posted about a Servlet Context Listener starting up
Hibernate for you, what is wrong with the one given on the hibernate site
under the page title "Tomcat Event listener for Hibernate" at the URL
http://www.hibernate.org/133.html ?

The example code shows how to have the hibernate configuration read.  You
can easily put pool information in your hibernate.cfg.xml file so Hibernate
starts the DB Pool for you.  (I do that)  Additionally, it lists how, should
you need it, to have a DB Pool instance automatically given out when a
session object is created and how to remove it when a session is ended.

Lastly, if you use C3P0, BE VERY CAREFUL if you are using version 0.8.3 of
C3P0 - there is no proper DB Pool shutdown code in Hibernate if the pool is
of that type (I last checked Hibernate 2.1.6's pool shutdown code).
Proxool, EHCache, and various other pool software have code in the db class
shutdown method in as far as I know.  (I had to research this when I had a
memory issue and kept restarting my webapp yet memory usage kept rising and
I kept seeing new DB pools each webapp restart.)

Regards,
David

-Original Message-
From: Brian McGovern [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 1:41 PM
To: Struts Users Mailing List
Subject: Struts , hibernate, and DBCP


Im using struts, hibernate and dbcp connection pooling.  Everything works
fine but regarding my connection pool.  It gets intantiated on the first
time I request a connection from the DBCP pool.  I want it to create the
pool when tomcat starts.  I think i can do this with struts, but im not sure
how.  If using struts config for htis is not the answer i;d still like to
know what is.

-thanks

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


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


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



RE: Struts , hibernate, and DBCP

2005-03-29 Thread David G. Friedman
Brian,

If you use a Tomcat resource reference to initialize your DB pool, be
careful where you put it: the location you place that init reference makes
the difference between YOUR webapp using the hibernate pool and ANY webapp
being able to use your hibernate pool.

Now, since someone posted about a Servlet Context Listener starting up
Hibernate for you, what is wrong with the one given on the hibernate site
under the page title "Tomcat Event listener for Hibernate" at the URL
http://www.hibernate.org/133.html ?

The example code shows how to have the hibernate configuration read.  You
can easily put pool information in your hibernate.cfg.xml file so Hibernate
starts the DB Pool for you.  (I do that)  Additionally, it lists how, should
you need it, to have a DB Pool instance automatically given out when a
session object is created and how to remove it when a session is ended.

Lastly, if you use C3P0, BE VERY CAREFUL if you are using version 0.8.3 of
C3P0 - there is no proper DB Pool shutdown code in Hibernate if the pool is
of that type (I last checked Hibernate 2.1.6's pool shutdown code).
Proxool, EHCache, and various other pool software have code in the db class
shutdown method in as far as I know.  (I had to research this when I had a
memory issue and kept restarting my webapp yet memory usage kept rising and
I kept seeing new DB pools each webapp restart.)

Regards,
David

-Original Message-
From: Brian McGovern [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 1:41 PM
To: Struts Users Mailing List
Subject: Struts , hibernate, and DBCP


Im using struts, hibernate and dbcp connection pooling.  Everything works
fine but regarding my connection pool.  It gets intantiated on the first
time I request a connection from the DBCP pool.  I want it to create the
pool when tomcat starts.  I think i can do this with struts, but im not sure
how.  If using struts config for htis is not the answer i;d still like to
know what is.

-thanks

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


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



Re: Struts , hibernate, and DBCP

2005-03-29 Thread N G
Sure.

Here is the code I have for a testApp I have to run tests in (for
Hibernate). Not sure it's such a great practice to stick the
SessionFactory onto ServletContext as far as best practices for
Hibernate are concerned (new to Hibernate), but it works for my small
Hibernate tests.

So,
Step 1: Define your class implementing ServletContextListener:

package testHibernate;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;


public class AppInitializer implements ServletContextListener
{

   public void contextInitialized(ServletContextEvent sce)
   {
  try
  {
 Configuration configuration = new Configuration();
 SessionFactory sessionFactory =
configuration.configure().buildSessionFactory();
 
 // Save SessionFactory into ServletContext
 sce.getServletContext().setAttribute("sessionFactory", sessionFactory);
  }
  catch (Throwable ex)
  {
 // We have to catch Throwable, otherwise we will miss
 // NoClassDefFoundError and other subclasses of Error
 System.out.println("Error occured!");
 System.out.println("Error was " + ex.getMessage());
 throw new ExceptionInInitializerError(ex);
  }
  
   }


   public void contextDestroyed(ServletContextEvent arg0)
   { 
   }
}



Step 2: Declare the listener in your web.xml:

---
http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee  
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>
   
 testHibernate.AppInitializer
   
   
  action
  org.apache.struts.action.ActionServlet
  
 config
 /WEB-INF/struts-config.xml
  
  
 debug
 3
  
  
 detail
 3
  
  0
   
   
---

That's pretty much it. When the web app starts up, as the very first
thing it will invoke your contextInitialized() method. The method
contextDestroyed() will be called as the very last thing before the
app shuts down.

That's it.

HTH,
NG.


On Tue, 29 Mar 2005 16:39:41 -0500, Brian McGovern
<[EMAIL PROTECTED]> wrote:
> Ok..  Im not to sure how that works.  Can you explain a little more?
> 
> -Original Message-
> From: N G [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 29, 2005 4:34 PM
> To: Struts Users Mailing List
> Subject: Re: Struts , hibernate, and DBCP
> 
> Oh... I didn't know that DBCP doesn't initialize the pool on server
> startup and thus misunderstood your question.
> 
> Truth is, if you want to go the easiest route, without having to make
> your own Controller, you can just configure your Hibernate
> SessionFactory in a listener
> (ServletContextListener.contextInitialized()). It will FOR SURE fire
> up on start up of your application before struts action servlet is
> even loaded.
> 
> HTH,
> NG.
> 
> On Tue, 29 Mar 2005 14:58:12 -0500, Erik Weber <[EMAIL PROTECTED]> wrote:
> > In my opinion, the question is on topic.
> >
> > I'm not sure whether by "instantiated" you mean the pool class or the
> > connection class. If it's the former, I'm not sure of the answer, but I
> > would assume that the pool class typically is instantiated at server
> > startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I
> > think specifying the minimum connection count property (> 0) in your
> > datasource config should cause the pool to be primed right after
> > startup. But, it's up to the pool implementation of course. But the
> > minimum connection count is supposed to keep the pool from going dry.
> >
> > Erik
> >
> >
> > N G wrote:
> >
> > >This has nothing to do with Struts:
> > >http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
> > >
> > >Good luck,
> > >NG.
> > >
> > >
> > >On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
> > ><[EMAIL PROTECTED]> wrote:
> > >
> > >
> > >>Im using struts, hibernate and dbcp connection pooling.  Everything works 
> > >>fine but regarding my connection pool.  It gets intantiated on the first 
> > >>time I request a connection from the DBCP pool.  I want it to create the 
> > >>pool when tomcat starts.  I think i can do this with struts, but im not 
> > >>sure how.  If using struts config for htis i

RE: Struts , hibernate, and DBCP

2005-03-29 Thread Brian McGovern
Ok..  Im not to sure how that works.  Can you explain a little more?

-Original Message-
From: N G [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 4:34 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP


Oh... I didn't know that DBCP doesn't initialize the pool on server
startup and thus misunderstood your question.

Truth is, if you want to go the easiest route, without having to make
your own Controller, you can just configure your Hibernate
SessionFactory in a listener
(ServletContextListener.contextInitialized()). It will FOR SURE fire
up on start up of your application before struts action servlet is
even loaded.

HTH,
NG.


On Tue, 29 Mar 2005 14:58:12 -0500, Erik Weber <[EMAIL PROTECTED]> wrote:
> In my opinion, the question is on topic.
> 
> I'm not sure whether by "instantiated" you mean the pool class or the
> connection class. If it's the former, I'm not sure of the answer, but I
> would assume that the pool class typically is instantiated at server
> startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I
> think specifying the minimum connection count property (> 0) in your
> datasource config should cause the pool to be primed right after
> startup. But, it's up to the pool implementation of course. But the
> minimum connection count is supposed to keep the pool from going dry.
> 
> Erik
> 
> 
> N G wrote:
> 
> >This has nothing to do with Struts:
> >http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
> >
> >Good luck,
> >NG.
> >
> >
> >On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
> ><[EMAIL PROTECTED]> wrote:
> >
> >
> >>Im using struts, hibernate and dbcp connection pooling.  Everything works 
> >>fine but regarding my connection pool.  It gets intantiated on the first 
> >>time I request a connection from the DBCP pool.  I want it to create the 
> >>pool when tomcat starts.  I think i can do this with struts, but im not 
> >>sure how.  If using struts config for htis is not the answer i;d still like 
> >>to know what is.
> >>
> >>-thanks
> >>
> >>-
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >>
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

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


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



RE: Struts , hibernate, and DBCP

2005-03-29 Thread Brian McGovern
ARRG>... but someone beat me to it! hahhahaha

-Original Message-
From: Brian McGovern [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 4:38 PM
To: Struts Users Mailing List
Subject: RE: Struts , hibernate, and DBCP


This is the first time i actually get to help someone in this user list rather 
than asking a million questions like a little kid..

I ran into a bunch of problems with the microsoft driver. UGH>. horrible.  It 
would double my pool size if the app was idle overnight.  It wouldnt re-connect 
if the db server was shut down or I mannually killed the thread.  drove me 
nuts.  

Try JTDS.  It seemed to be highly recommened and it cleared up all the problems 
i was having with db -reconnects and pool size integrity.  
http://jtds.sourceforge.net/

Driver name is net.sourceforge.jtds.jdbc.Driver
URL Syntax looks like 
jdbc:jtds:sqlserver://:/



-Original Message-
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 4:00 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP


If you are using SQL Server, I would say, watch out for the drivers as 
much as the DataSource implementation. I have read and heard many horror 
stories about the Microsoft drivers and have experienced problems myself 
(though pinpointing them is another matter). There are third party 
drivers out there that claim to be much better. I could use a good one 
myself . . .

Erik


Brian McGovern wrote:

>Well all the folks in the Hibernate boards seem to favor either Proxool or 
>C3P0.  I've heard about the complaints on DBCP and am using SQL Server for 
>this implementation so i'll watch out for connection leaks.  It's really not 
>that hard to switch the pooler, I'll probably give c3p0 a shot with and 
>without my extended base class and see what happens there.
>
>-B
>
>-Original Message-
>From: Erik Weber [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, March 29, 2005 3:46 PM
>To: Struts Users Mailing List
>Subject: Re: Struts , hibernate, and DBCP
>
>
>Interesting. Yeah, I was going to suggest writing some "trigger" code 
>for startup, and it looks like that's what you have done. Also, you're 
>not stuck with DBCP. There are many DataSource implementations out 
>there, including others that are open source. I was hoping to get around 
>to reviewing them all one day. . . I have had problems with DBCP leaking 
>connections when used with some databases (Oracle and SQL Server 2000). 
>It could be a vendor-specific problem though, because DBCP seems to work 
>great with ConnectorJ/MySQL.
>
>Erik
>
>
>Brian McGovern wrote:
>
>  
>
>>Eric Thanks for response.  I wrote a follow up that explained my work around. 
>> But to your points, in using commons-dbcp and specifying the initial pool 
>>size of 5, you'd think that it would fire up the pool on application start 
>>but it doesnt.  In code, you have to request a connection from the JNDI 
>>resource in order for the pool to be created.  
>>
>>
>>-Original Message-
>>From: Erik Weber [mailto:[EMAIL PROTECTED]
>>Sent: Tuesday, March 29, 2005 2:58 PM
>>To: Struts Users Mailing List
>>Subject: Re: Struts , hibernate, and DBCP
>>
>>
>>In my opinion, the question is on topic.
>>
>>I'm not sure whether by "instantiated" you mean the pool class or the 
>>connection class. If it's the former, I'm not sure of the answer, but I 
>>would assume that the pool class typically is instantiated at server 
>>startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I 
>>think specifying the minimum connection count property (> 0) in your 
>>datasource config should cause the pool to be primed right after 
>>startup. But, it's up to the pool implementation of course. But the 
>>minimum connection count is supposed to keep the pool from going dry.
>>
>>Erik
>>
>>
>>N G wrote:
>>
>> 
>>
>>
>>
>>>This has nothing to do with Struts:
>>>http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
>>>
>>>Good luck,
>>>NG.
>>>
>>>
>>>On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
>>><[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>   
>>>
>>>  
>>>
>>>>Im using struts, hibernate and dbcp connection pooling.  Everything works 
>>>>fine but regarding my connection pool.  It gets intantiated on the first 
>>>>time I request a connection from the DBCP pool.  I want it to create the 
>>>>pool when tomcat 

RE: Struts , hibernate, and DBCP

2005-03-29 Thread Brian McGovern
This is the first time i actually get to help someone in this user list rather 
than asking a million questions like a little kid..

I ran into a bunch of problems with the microsoft driver. UGH>. horrible.  It 
would double my pool size if the app was idle overnight.  It wouldnt re-connect 
if the db server was shut down or I mannually killed the thread.  drove me 
nuts.  

Try JTDS.  It seemed to be highly recommened and it cleared up all the problems 
i was having with db -reconnects and pool size integrity.  
http://jtds.sourceforge.net/

Driver name is net.sourceforge.jtds.jdbc.Driver
URL Syntax looks like 
jdbc:jtds:sqlserver://:/



-Original Message-
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 4:00 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP


If you are using SQL Server, I would say, watch out for the drivers as 
much as the DataSource implementation. I have read and heard many horror 
stories about the Microsoft drivers and have experienced problems myself 
(though pinpointing them is another matter). There are third party 
drivers out there that claim to be much better. I could use a good one 
myself . . .

Erik


Brian McGovern wrote:

>Well all the folks in the Hibernate boards seem to favor either Proxool or 
>C3P0.  I've heard about the complaints on DBCP and am using SQL Server for 
>this implementation so i'll watch out for connection leaks.  It's really not 
>that hard to switch the pooler, I'll probably give c3p0 a shot with and 
>without my extended base class and see what happens there.
>
>-B
>
>-Original Message-
>From: Erik Weber [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, March 29, 2005 3:46 PM
>To: Struts Users Mailing List
>Subject: Re: Struts , hibernate, and DBCP
>
>
>Interesting. Yeah, I was going to suggest writing some "trigger" code 
>for startup, and it looks like that's what you have done. Also, you're 
>not stuck with DBCP. There are many DataSource implementations out 
>there, including others that are open source. I was hoping to get around 
>to reviewing them all one day. . . I have had problems with DBCP leaking 
>connections when used with some databases (Oracle and SQL Server 2000). 
>It could be a vendor-specific problem though, because DBCP seems to work 
>great with ConnectorJ/MySQL.
>
>Erik
>
>
>Brian McGovern wrote:
>
>  
>
>>Eric Thanks for response.  I wrote a follow up that explained my work around. 
>> But to your points, in using commons-dbcp and specifying the initial pool 
>>size of 5, you'd think that it would fire up the pool on application start 
>>but it doesnt.  In code, you have to request a connection from the JNDI 
>>resource in order for the pool to be created.  
>>
>>
>>-Original Message-
>>From: Erik Weber [mailto:[EMAIL PROTECTED]
>>Sent: Tuesday, March 29, 2005 2:58 PM
>>To: Struts Users Mailing List
>>Subject: Re: Struts , hibernate, and DBCP
>>
>>
>>In my opinion, the question is on topic.
>>
>>I'm not sure whether by "instantiated" you mean the pool class or the 
>>connection class. If it's the former, I'm not sure of the answer, but I 
>>would assume that the pool class typically is instantiated at server 
>>startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I 
>>think specifying the minimum connection count property (> 0) in your 
>>datasource config should cause the pool to be primed right after 
>>startup. But, it's up to the pool implementation of course. But the 
>>minimum connection count is supposed to keep the pool from going dry.
>>
>>Erik
>>
>>
>>N G wrote:
>>
>> 
>>
>>
>>
>>>This has nothing to do with Struts:
>>>http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
>>>
>>>Good luck,
>>>NG.
>>>
>>>
>>>On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
>>><[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>   
>>>
>>>  
>>>
>>>>Im using struts, hibernate and dbcp connection pooling.  Everything works 
>>>>fine but regarding my connection pool.  It gets intantiated on the first 
>>>>time I request a connection from the DBCP pool.  I want it to create the 
>>>>pool when tomcat starts.  I think i can do this with struts, but im not 
>>>>sure how.  If using struts config for htis is not the answer i;d still like 
>>>>to know what is.
>>>>
>>>&g

Re: Struts , hibernate, and DBCP

2005-03-29 Thread Erik Weber

Kris Schneider wrote:
Erik Weber wrote:
If you are using SQL Server, I would say, watch out for the drivers 
as much as the DataSource implementation. I have read and heard many 
horror stories about the Microsoft drivers and have experienced 
problems myself (though pinpointing them is another matter). There 
are third party drivers out there that claim to be much better. I 
could use a good one myself . . .

Have you tried: http://jtds.sourceforge.net/
Ah, I saw this once and meant to get back to it. Thanks!
Erik
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Struts , hibernate, and DBCP

2005-03-29 Thread N G
Oh... I didn't know that DBCP doesn't initialize the pool on server
startup and thus misunderstood your question.

Truth is, if you want to go the easiest route, without having to make
your own Controller, you can just configure your Hibernate
SessionFactory in a listener
(ServletContextListener.contextInitialized()). It will FOR SURE fire
up on start up of your application before struts action servlet is
even loaded.

HTH,
NG.


On Tue, 29 Mar 2005 14:58:12 -0500, Erik Weber <[EMAIL PROTECTED]> wrote:
> In my opinion, the question is on topic.
> 
> I'm not sure whether by "instantiated" you mean the pool class or the
> connection class. If it's the former, I'm not sure of the answer, but I
> would assume that the pool class typically is instantiated at server
> startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I
> think specifying the minimum connection count property (> 0) in your
> datasource config should cause the pool to be primed right after
> startup. But, it's up to the pool implementation of course. But the
> minimum connection count is supposed to keep the pool from going dry.
> 
> Erik
> 
> 
> N G wrote:
> 
> >This has nothing to do with Struts:
> >http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
> >
> >Good luck,
> >NG.
> >
> >
> >On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
> ><[EMAIL PROTECTED]> wrote:
> >
> >
> >>Im using struts, hibernate and dbcp connection pooling.  Everything works 
> >>fine but regarding my connection pool.  It gets intantiated on the first 
> >>time I request a connection from the DBCP pool.  I want it to create the 
> >>pool when tomcat starts.  I think i can do this with struts, but im not 
> >>sure how.  If using struts config for htis is not the answer i;d still like 
> >>to know what is.
> >>
> >>-thanks
> >>
> >>-
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >>
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

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



Re: Struts , hibernate, and DBCP

2005-03-29 Thread Kris Schneider
Erik Weber wrote:
If you are using SQL Server, I would say, watch out for the drivers as 
much as the DataSource implementation. I have read and heard many horror 
stories about the Microsoft drivers and have experienced problems myself 
(though pinpointing them is another matter). There are third party 
drivers out there that claim to be much better. I could use a good one 
myself . . .
Have you tried: http://jtds.sourceforge.net/
Erik
Brian McGovern wrote:
Well all the folks in the Hibernate boards seem to favor either 
Proxool or C3P0.  I've heard about the complaints on DBCP and am using 
SQL Server for this implementation so i'll watch out for connection 
leaks.  It's really not that hard to switch the pooler, I'll probably 
give c3p0 a shot with and without my extended base class and see what 
happens there.

-B
-Original Message-
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 3:46 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP
Interesting. Yeah, I was going to suggest writing some "trigger" code 
for startup, and it looks like that's what you have done. Also, you're 
not stuck with DBCP. There are many DataSource implementations out 
there, including others that are open source. I was hoping to get 
around to reviewing them all one day. . . I have had problems with 
DBCP leaking connections when used with some databases (Oracle and SQL 
Server 2000). It could be a vendor-specific problem though, because 
DBCP seems to work great with ConnectorJ/MySQL.

Erik
Brian McGovern wrote:
 

Eric Thanks for response.  I wrote a follow up that explained my work 
around.  But to your points, in using commons-dbcp and specifying the 
initial pool size of 5, you'd think that it would fire up the pool on 
application start but it doesnt.  In code, you have to request a 
connection from the JNDI resource in order for the pool to be created. 

-Original Message-
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 2:58 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP
In my opinion, the question is on topic.
I'm not sure whether by "instantiated" you mean the pool class or the 
connection class. If it's the former, I'm not sure of the answer, but 
I would assume that the pool class typically is instantiated at 
server startup. If not, wouldn't the JNDI lookup fail? If it's the 
latter, I think specifying the minimum connection count property (> 
0) in your datasource config should cause the pool to be primed right 
after startup. But, it's up to the pool implementation of course. But 
the minimum connection count is supposed to keep the pool from going 
dry.

Erik
N G wrote:

  

This has nothing to do with Struts:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html 

Good luck,
NG.
On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
<[EMAIL PROTECTED]> wrote:
 


Im using struts, hibernate and dbcp connection pooling.  Everything 
works fine but regarding my connection pool.  It gets intantiated 
on the first time I request a connection from the DBCP pool.  I 
want it to create the pool when tomcat starts.  I think i can do 
this with struts, but im not sure how.  If using struts config for 
htis is not the answer i;d still like to know what is.

-thanks
--
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech   <http://www.dotech.com/>
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Struts , hibernate, and DBCP

2005-03-29 Thread Erik Weber
If you are using SQL Server, I would say, watch out for the drivers as 
much as the DataSource implementation. I have read and heard many horror 
stories about the Microsoft drivers and have experienced problems myself 
(though pinpointing them is another matter). There are third party 
drivers out there that claim to be much better. I could use a good one 
myself . . .

Erik
Brian McGovern wrote:
Well all the folks in the Hibernate boards seem to favor either Proxool or 
C3P0.  I've heard about the complaints on DBCP and am using SQL Server for this 
implementation so i'll watch out for connection leaks.  It's really not that 
hard to switch the pooler, I'll probably give c3p0 a shot with and without my 
extended base class and see what happens there.
-B
-Original Message-
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 3:46 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP
Interesting. Yeah, I was going to suggest writing some "trigger" code 
for startup, and it looks like that's what you have done. Also, you're 
not stuck with DBCP. There are many DataSource implementations out 
there, including others that are open source. I was hoping to get around 
to reviewing them all one day. . . I have had problems with DBCP leaking 
connections when used with some databases (Oracle and SQL Server 2000). 
It could be a vendor-specific problem though, because DBCP seems to work 
great with ConnectorJ/MySQL.

Erik
Brian McGovern wrote:
 

Eric Thanks for response.  I wrote a follow up that explained my work around.  But to your points, in using commons-dbcp and specifying the initial pool size of 5, you'd think that it would fire up the pool on application start but it doesnt.  In code, you have to request a connection from the JNDI resource in order for the pool to be created.  

-Original Message-
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 2:58 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP
In my opinion, the question is on topic.
I'm not sure whether by "instantiated" you mean the pool class or the 
connection class. If it's the former, I'm not sure of the answer, but I 
would assume that the pool class typically is instantiated at server 
startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I 
think specifying the minimum connection count property (> 0) in your 
datasource config should cause the pool to be primed right after 
startup. But, it's up to the pool implementation of course. But the 
minimum connection count is supposed to keep the pool from going dry.

Erik
N G wrote:

   

This has nothing to do with Struts:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
Good luck,
NG.
On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
<[EMAIL PROTECTED]> wrote:
  

 

Im using struts, hibernate and dbcp connection pooling.  Everything works fine 
but regarding my connection pool.  It gets intantiated on the first time I 
request a connection from the DBCP pool.  I want it to create the pool when 
tomcat starts.  I think i can do this with struts, but im not sure how.  If 
using struts config for htis is not the answer i;d still like to know what is.
-thanks
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



   

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

  

 

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

   

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

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


RE: Struts , hibernate, and DBCP

2005-03-29 Thread Brian McGovern
Well all the folks in the Hibernate boards seem to favor either Proxool or 
C3P0.  I've heard about the complaints on DBCP and am using SQL Server for this 
implementation so i'll watch out for connection leaks.  It's really not that 
hard to switch the pooler, I'll probably give c3p0 a shot with and without my 
extended base class and see what happens there.

-B

-Original Message-
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 3:46 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP


Interesting. Yeah, I was going to suggest writing some "trigger" code 
for startup, and it looks like that's what you have done. Also, you're 
not stuck with DBCP. There are many DataSource implementations out 
there, including others that are open source. I was hoping to get around 
to reviewing them all one day. . . I have had problems with DBCP leaking 
connections when used with some databases (Oracle and SQL Server 2000). 
It could be a vendor-specific problem though, because DBCP seems to work 
great with ConnectorJ/MySQL.

Erik


Brian McGovern wrote:

>Eric Thanks for response.  I wrote a follow up that explained my work around.  
>But to your points, in using commons-dbcp and specifying the initial pool size 
>of 5, you'd think that it would fire up the pool on application start but it 
>doesnt.  In code, you have to request a connection from the JNDI resource in 
>order for the pool to be created.  
>
>
>-Original Message-
>From: Erik Weber [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, March 29, 2005 2:58 PM
>To: Struts Users Mailing List
>Subject: Re: Struts , hibernate, and DBCP
>
>
>In my opinion, the question is on topic.
>
>I'm not sure whether by "instantiated" you mean the pool class or the 
>connection class. If it's the former, I'm not sure of the answer, but I 
>would assume that the pool class typically is instantiated at server 
>startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I 
>think specifying the minimum connection count property (> 0) in your 
>datasource config should cause the pool to be primed right after 
>startup. But, it's up to the pool implementation of course. But the 
>minimum connection count is supposed to keep the pool from going dry.
>
>Erik
>
>
>N G wrote:
>
>  
>
>>This has nothing to do with Struts:
>>http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
>>
>>Good luck,
>>NG.
>>
>>
>>On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
>><[EMAIL PROTECTED]> wrote:
>> 
>>
>>
>>
>>>Im using struts, hibernate and dbcp connection pooling.  Everything works 
>>>fine but regarding my connection pool.  It gets intantiated on the first 
>>>time I request a connection from the DBCP pool.  I want it to create the 
>>>pool when tomcat starts.  I think i can do this with struts, but im not sure 
>>>how.  If using struts config for htis is not the answer i;d still like to 
>>>know what is.
>>>
>>>-thanks
>>>
>>>-
>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>   
>>>
>>>  
>>>
>>-
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>> 
>>
>>
>>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>  
>

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


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



Re: Struts , hibernate, and DBCP

2005-03-29 Thread Erik Weber
Interesting. Yeah, I was going to suggest writing some "trigger" code 
for startup, and it looks like that's what you have done. Also, you're 
not stuck with DBCP. There are many DataSource implementations out 
there, including others that are open source. I was hoping to get around 
to reviewing them all one day. . . I have had problems with DBCP leaking 
connections when used with some databases (Oracle and SQL Server 2000). 
It could be a vendor-specific problem though, because DBCP seems to work 
great with ConnectorJ/MySQL.

Erik
Brian McGovern wrote:
Eric Thanks for response.  I wrote a follow up that explained my work around.  But to your points, in using commons-dbcp and specifying the initial pool size of 5, you'd think that it would fire up the pool on application start but it doesnt.  In code, you have to request a connection from the JNDI resource in order for the pool to be created.  

-Original Message-
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 2:58 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP
In my opinion, the question is on topic.
I'm not sure whether by "instantiated" you mean the pool class or the 
connection class. If it's the former, I'm not sure of the answer, but I 
would assume that the pool class typically is instantiated at server 
startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I 
think specifying the minimum connection count property (> 0) in your 
datasource config should cause the pool to be primed right after 
startup. But, it's up to the pool implementation of course. But the 
minimum connection count is supposed to keep the pool from going dry.

Erik
N G wrote:
 

This has nothing to do with Struts:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
Good luck,
NG.
On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
<[EMAIL PROTECTED]> wrote:
   

Im using struts, hibernate and dbcp connection pooling.  Everything works fine 
but regarding my connection pool.  It gets intantiated on the first time I 
request a connection from the DBCP pool.  I want it to create the pool when 
tomcat starts.  I think i can do this with struts, but im not sure how.  If 
using struts config for htis is not the answer i;d still like to know what is.
-thanks
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
  

 

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

   

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

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


RE: Struts , hibernate, and DBCP

2005-03-29 Thread Brian McGovern
Eric Thanks for response.  I wrote a follow up that explained my work around.  
But to your points, in using commons-dbcp and specifying the initial pool size 
of 5, you'd think that it would fire up the pool on application start but it 
doesnt.  In code, you have to request a connection from the JNDI resource in 
order for the pool to be created.  


-Original Message-
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 2:58 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP


In my opinion, the question is on topic.

I'm not sure whether by "instantiated" you mean the pool class or the 
connection class. If it's the former, I'm not sure of the answer, but I 
would assume that the pool class typically is instantiated at server 
startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I 
think specifying the minimum connection count property (> 0) in your 
datasource config should cause the pool to be primed right after 
startup. But, it's up to the pool implementation of course. But the 
minimum connection count is supposed to keep the pool from going dry.

Erik


N G wrote:

>This has nothing to do with Struts:
>http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
>
>Good luck,
>NG.
>
>
>On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
><[EMAIL PROTECTED]> wrote:
>  
>
>>Im using struts, hibernate and dbcp connection pooling.  Everything works 
>>fine but regarding my connection pool.  It gets intantiated on the first time 
>>I request a connection from the DBCP pool.  I want it to create the pool when 
>>tomcat starts.  I think i can do this with struts, but im not sure how.  If 
>>using struts config for htis is not the answer i;d still like to know what is.
>>
>>-thanks
>>
>>-
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>  
>

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


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



Re: Struts , hibernate, and DBCP

2005-03-29 Thread Erik Weber
In my opinion, the question is on topic.
I'm not sure whether by "instantiated" you mean the pool class or the 
connection class. If it's the former, I'm not sure of the answer, but I 
would assume that the pool class typically is instantiated at server 
startup. If not, wouldn't the JNDI lookup fail? If it's the latter, I 
think specifying the minimum connection count property (> 0) in your 
datasource config should cause the pool to be primed right after 
startup. But, it's up to the pool implementation of course. But the 
minimum connection count is supposed to keep the pool from going dry.

Erik
N G wrote:
This has nothing to do with Struts:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
Good luck,
NG.
On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
<[EMAIL PROTECTED]> wrote:
 

Im using struts, hibernate and dbcp connection pooling.  Everything works fine 
but regarding my connection pool.  It gets intantiated on the first time I 
request a connection from the DBCP pool.  I want it to create the pool when 
tomcat starts.  I think i can do this with struts, but im not sure how.  If 
using struts config for htis is not the answer i;d still like to know what is.
-thanks
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   

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

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


RE: Struts , hibernate, and DBCP [solution] - but would like opinions on my approach

2005-03-29 Thread Brian McGovern
I read that.  And that doesn't explain how to create your pool on application 
server startup.  It only explains how to create a pool on first data call.  

I worked around my problem "in struts" by creating a new base Controller as my 
action servlet which extends "ActionServlet". 

action
 
com.imediainc.pcmexchange.control.PCMBaseControllerServlet

That Controller servlet is load-on-startup so it executes as my webapp starts.  
Inside it it calls my Hibernate session factory which instantiates my pool.  So 
I do have it worked out that when I start tomcat, my pool is created.  But im 
not sure this approach is sound.  I'm all ears for alternatives.

In general, I'm new to the concept of extending the struts front controller and 
don't know if putting a data connection getter in there is a bad practice or 
not.  I think this would be a good place to instantiate a centralized logger 
too, etc.

Thanks
-B

-Original Message-
From: N G [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 29, 2005 2:36 PM
To: Struts Users Mailing List
Subject: Re: Struts , hibernate, and DBCP


This has nothing to do with Struts:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html

Good luck,
NG.


On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
<[EMAIL PROTECTED]> wrote:
> Im using struts, hibernate and dbcp connection pooling.  Everything works 
> fine but regarding my connection pool.  It gets intantiated on the first time 
> I request a connection from the DBCP pool.  I want it to create the pool when 
> tomcat starts.  I think i can do this with struts, but im not sure how.  If 
> using struts config for htis is not the answer i;d still like to know what is.
> 
> -thanks
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

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


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



Re: Struts , hibernate, and DBCP

2005-03-29 Thread N G
This has nothing to do with Struts:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html

Good luck,
NG.


On Tue, 29 Mar 2005 13:40:56 -0500, Brian McGovern
<[EMAIL PROTECTED]> wrote:
> Im using struts, hibernate and dbcp connection pooling.  Everything works 
> fine but regarding my connection pool.  It gets intantiated on the first time 
> I request a connection from the DBCP pool.  I want it to create the pool when 
> tomcat starts.  I think i can do this with struts, but im not sure how.  If 
> using struts config for htis is not the answer i;d still like to know what is.
> 
> -thanks
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

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