You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Scott Purcell <sp...@vertisinc.com> on 2005/04/11 14:56:03 UTC
Need Database Connectivity Advice
I am at a crossroads of information today, and could use some advice. Prior to using the Struts framework, I had a roll-your-own database pooling solution that of course required threads and Vectors of connections, etc. Upon the start of another new project, I found myself Friday trying to figure out how to use the DBCP classes inside my Tomcat server. As I do not understand the JNDI, etc. I had some trouble Friday and over the weekend, getting all configured. And when I did get it work work by their simple example, I ended up connecting in a JSP page, and that is not what I want.
So reflecting to my book OReilly/Struts, I noticed that they use a database persistance product. Something called ObjectRelationalBridge, and use it with some design patterns that I am having trouble following. I would like to possbily go this route, but I am confused at the Factory references, etc. I don't know why I am having trouble understanding this, but I am.
I had the weekend to try and get my bearings on how to start this new web-app, and build it so I can war up and host at an ISP. I figured each user on this list probably already connects, and has some great ideas to throw my way.
I could really use some advice, on selecting the correct, both easy to use, and reusable in the future solution for my connectivity dilemma. The reason I found DBCP confusing, is that the directions for the Tomcat 5.5 show a JSP page, using JSTL commands, and I really do not want to connect in JSP pages.
I would really appreciate any input, advice, links, how to advice, etc.
Sincerely
Scott K Purcell
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Need Database Connectivity Advice
Posted by Duncan Mills <du...@oracle.com>.
Depending on your feelings towards paying for an O/R mapping solution,
there are two long established O/R mapping mechanisms from Oracle.
* TopLink
(http://www.oracle.com/technology/products/ias/toplink/index.html)
* ADF Business Components
(http://www.oracle.com/technology/products/jdev/index.html)
I'd recommend Business Components if you are from a relational
background and tend to do your DB design up front and TopLink if the
reverse is true and / or you don't have as much control as you'd like
over the relational side and need more complex mapping capabilities.
Both frameworks handle pooling caching and so forth for you as you'd expect
With either framework you can integrate with Struts directly through
code, or using the ADF Model framework
<http://www.oracle.com/technology/products/jdev/collateral/papers/10g/adfm_overview.pdf>
handle UI binding and method invocation from Struts Actions declaratively.
It's worth running through the online tour
<http://www.oracle.com/technology/products/jdev/viewlets/10g/ADFOverview_viewlet_swf.html>
to get an idea what it's all about in any case, more to illustrate the
levels of productivity O/R mapping frameworks should aspire to if
nothing else.
Duncan
http://www.groundside.com/blog
Scott Purcell wrote:
>I am at a crossroads of information today, and could use some advice. Prior to using the Struts framework, I had a roll-your-own database pooling solution that of course required threads and Vectors of connections, etc. Upon the start of another new project, I found myself Friday trying to figure out how to use the DBCP classes inside my Tomcat server. As I do not understand the JNDI, etc. I had some trouble Friday and over the weekend, getting all configured. And when I did get it work work by their simple example, I ended up connecting in a JSP page, and that is not what I want.
>
>So reflecting to my book OReilly/Struts, I noticed that they use a database persistance product. Something called ObjectRelationalBridge, and use it with some design patterns that I am having trouble following. I would like to possbily go this route, but I am confused at the Factory references, etc. I don't know why I am having trouble understanding this, but I am.
>
>I had the weekend to try and get my bearings on how to start this new web-app, and build it so I can war up and host at an ISP. I figured each user on this list probably already connects, and has some great ideas to throw my way.
>
>I could really use some advice, on selecting the correct, both easy to use, and reusable in the future solution for my connectivity dilemma. The reason I found DBCP confusing, is that the directions for the Tomcat 5.5 show a JSP page, using JSTL commands, and I really do not want to connect in JSP pages.
>
>I would really appreciate any input, advice, links, how to advice, etc.
>
>Sincerely
>Scott K Purcell
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
Re: Need Database Connectivity Advice
Posted by Tom Ziemer <t....@dkfz-heidelberg.de>.
Hi,
you might want to take a look at Hibernate (www.hibernate.org). It's a
powerful yet (fairly) easy to use persistence layer, that can even be
used with an existing database schema (Middlegen). There is also a lot
of documentation (on- and offline) available for this project.
Regards,
Tom
Scott Purcell wrote:
> I am at a crossroads of information today, and could use some advice. Prior to using the Struts framework, I had a roll-your-own database pooling solution that of course required threads and Vectors of connections, etc. Upon the start of another new project, I found myself Friday trying to figure out how to use the DBCP classes inside my Tomcat server. As I do not understand the JNDI, etc. I had some trouble Friday and over the weekend, getting all configured. And when I did get it work work by their simple example, I ended up connecting in a JSP page, and that is not what I want.
>
> So reflecting to my book OReilly/Struts, I noticed that they use a database persistance product. Something called ObjectRelationalBridge, and use it with some design patterns that I am having trouble following. I would like to possbily go this route, but I am confused at the Factory references, etc. I don't know why I am having trouble understanding this, but I am.
>
> I had the weekend to try and get my bearings on how to start this new web-app, and build it so I can war up and host at an ISP. I figured each user on this list probably already connects, and has some great ideas to throw my way.
>
> I could really use some advice, on selecting the correct, both easy to use, and reusable in the future solution for my connectivity dilemma. The reason I found DBCP confusing, is that the directions for the Tomcat 5.5 show a JSP page, using JSTL commands, and I really do not want to connect in JSP pages.
>
> I would really appreciate any input, advice, links, how to advice, etc.
>
> Sincerely
> Scott K Purcell
>
>
>
> ---------------------------------------------------------------------
> 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: Need Database Connectivity Advice
Posted by David Evans <ds...@berndtgroup.net>.
Here's how i use the tomcat database pool.
(these are just the relevent snippets, if you need the
entire source, email me off list and i'll email you the entire DAO)
In my DAO:
import javax.sql.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.sql.Connection;
import java.sql.Statement;
Statement stmt = null;
Connection conn = null;
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:com/env")
DataSource ds = (DataSource) envCtx.lookup("jdbc/mediatwo");
conn = ds.getConnection();
stmt = conn.createStatement();
// run query, get results etc
}
The key in the look up line: envCtx.lookup("jdbc/mediatwo");
is the name from the tomcat database pool in server.xml:
<Resource name="jdbc/mediatwo" auth="Container"
type="javax.sql.DataSource" description="mysql mediatwodev db">
</Resource>
Hope that helps.
Dave
On Mon, 2005-04-11 at 08:56, Scott Purcell wrote:
> I am at a crossroads of information today, and could use some advice. Prior to using the Struts framework, I had a roll-your-own database pooling solution that of course required threads and Vectors of connections, etc. Upon the start of another new project, I found myself Friday trying to figure out how to use the DBCP classes inside my Tomcat server. As I do not understand the JNDI, etc. I had some trouble Friday and over the weekend, getting all configured. And when I did get it work work by their simple example, I ended up connecting in a JSP page, and that is not what I want.
>
> So reflecting to my book OReilly/Struts, I noticed that they use a database persistance product. Something called ObjectRelationalBridge, and use it with some design patterns that I am having trouble following. I would like to possbily go this route, but I am confused at the Factory references, etc. I don't know why I am having trouble understanding this, but I am.
>
> I had the weekend to try and get my bearings on how to start this new web-app, and build it so I can war up and host at an ISP. I figured each user on this list probably already connects, and has some great ideas to throw my way.
>
> I could really use some advice, on selecting the correct, both easy to use, and reusable in the future solution for my connectivity dilemma. The reason I found DBCP confusing, is that the directions for the Tomcat 5.5 show a JSP page, using JSTL commands, and I really do not want to connect in JSP pages.
>
> I would really appreciate any input, advice, links, how to advice, etc.
>
> Sincerely
> Scott K Purcell
>
>
>
> ---------------------------------------------------------------------
> 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