You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kevin Bridges <cy...@gmail.com> on 2004/10/30 01:29:27 UTC

database pooling for struts

Hi.  I am completely new at struts and fairly new to java ... so if
these questions are blatantly ignorant please be kind. If this email
is out of scope for this list, please notify me off-list.

I am interested in setting up database pooling for struts and have
been following a tutorial located at
http://www.arc-mind.com/chapters/strutsTut.pdf (p.27), which outlines
a process for doing so.

The tutorial makes reference to a struts-legacy.jar that ships with
Struts 1.1 along with commons-dbcp.jar and commons-pool.jar.  The
tutorial is completely written for Struts 1.1

I'm using Struts 1.2.4 on Tomcat 4.1 ... Should I continue to follow
the tutorials 1.1 path, or is there a better approach I can utilize
for Struts 1.2.4?  Any pointers to tutorials or additional reference
material is greatly appreciated.

Thanks.
Kevin Bridges

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


Re: database pooling for struts

Posted by Erik Weber <er...@mindspring.com>.
The accepted practice is to configure your connection pool just as you 
would for any other J2EE application and to not have any ties to Struts 
(though there once was a practice of declaring a "Struts" data source). 
Just declare your data source in web.xml, configure it in your Tomcat 
context XML file (or, I think, globally in server.xml) and look up the 
data source via JNDI (javax.naming.InitialContext.lookup) in your Java 
code. So you don't necessarily need a Struts-specific tutorial but 
rather a good J2EE/JDBC tutorial. Typically the documentation that comes 
with your server will suffice. I have found that the Tomcat and JBoss 
docs do a decent, if not stellar, job of this (speaking of Tomcat 5 and 
JBoss 3). You can also learn some things from the WebLogic documentation 
even if you aren't using WebLogic, as it is generally much further 
along, and, these days, spec compliance among servers tends to be pretty 
good.

I think DBCP is commonly used with Struts, but I have to be honest with 
you. I've never gotten it to work correctly with Oracle or SQL Server 
2000 (the pools always leak and connections are "burned up" eventually). 
But I have had success using it with MySQL. I know I'm not the only one 
who has had problems with DBCP and Oracle on this list, but maybe 
someone who has had some luck with it might post an example Tomcat 
context file with his working DBCP/Oracle config.

Also a lot of Struts users also use persistence frameworks instead, such 
as Hibernate and iBatis.

Erik



Kevin Bridges wrote:

>Hi.  I am completely new at struts and fairly new to java ... so if
>these questions are blatantly ignorant please be kind. If this email
>is out of scope for this list, please notify me off-list.
>
>I am interested in setting up database pooling for struts and have
>been following a tutorial located at
>http://www.arc-mind.com/chapters/strutsTut.pdf (p.27), which outlines
>a process for doing so.
>
>The tutorial makes reference to a struts-legacy.jar that ships with
>Struts 1.1 along with commons-dbcp.jar and commons-pool.jar.  The
>tutorial is completely written for Struts 1.1
>
>I'm using Struts 1.2.4 on Tomcat 4.1 ... Should I continue to follow
>the tutorials 1.1 path, or is there a better approach I can utilize
>for Struts 1.2.4?  Any pointers to tutorials or additional reference
>material is greatly appreciated.
>
>Thanks.
>Kevin Bridges
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>  
>

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


RE: database pooling for struts

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Kevin,

Some database software (such as Hibernate[.org]) can automatically
initialize a pool of database connections for you.  I use Hibernate (with a
Struts plugIn to set it up), one of the various pooling packages it
supports, and am trying to learn how to use some of the many data caching
packages available within it.   The database pooling includes (at least)
C3P0 (http://c3p0.sourceforge.net), DBCP
(http://jakarta.apache.org/commons/dbcp), and Proxool
(http://proxool.sourceforge.net).  For caces, it supports JCS, EhCache,
OSCache, TreeCache (JBoss), and probably more I can't think of right now.
Of course, with their base classes for both so you could always create your
own interface should your favorite pooling or caching software not be found
on their site or as a usable class file somewhere inside the great, old
Internet.

Regards,
David

-----Original Message-----
From: Kevin Bridges [mailto:cyberswat@gmail.com]
Sent: Friday, October 29, 2004 7:29 PM
To: user@struts.apache.org
Subject: database pooling for struts


Hi.  I am completely new at struts and fairly new to java ... so if
these questions are blatantly ignorant please be kind. If this email
is out of scope for this list, please notify me off-list.

I am interested in setting up database pooling for struts and have
been following a tutorial located at
http://www.arc-mind.com/chapters/strutsTut.pdf (p.27), which outlines
a process for doing so.

The tutorial makes reference to a struts-legacy.jar that ships with
Struts 1.1 along with commons-dbcp.jar and commons-pool.jar.  The
tutorial is completely written for Struts 1.1

I'm using Struts 1.2.4 on Tomcat 4.1 ... Should I continue to follow
the tutorials 1.1 path, or is there a better approach I can utilize
for Struts 1.2.4?  Any pointers to tutorials or additional reference
material is greatly appreciated.

Thanks.
Kevin Bridges

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


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