You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "C.F. Scheidecker Antunes" <na...@antunes.eti.br> on 2005/08/18 03:22:16 UTC

Database Best Practices

Hello all,

In order to access a Database on my Model layer, which one is best?

1) A DataSource declared on the struts-config.xml. Then get the 
DataSource on your code inside either your actions or business classes.

2) Create a class that will load the database Driver ,establish the 
connection and return a Connection object through a getConnection() 
static function?

It seems to me that the second is better although it takes a little more 
effort.

Any thoughts on that?

Thanks in advance,

C.F.

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


Re: Database Best Practices

Posted by Larry Meadors <la...@gmail.com>.
Here is one example:

http://ibatis.apache.org/petstore.html

It's use of struts is different, but the database access approach is solid.

Larry


On 8/17/05, C.F. Scheidecker Antunes <na...@antunes.eti.br> wrote:
> Hello all,
> 
> In order to access a Database on my Model layer, which one is best?
> 
> 1) A DataSource declared on the struts-config.xml. Then get the
> DataSource on your code inside either your actions or business classes.
> 
> 2) Create a class that will load the database Driver ,establish the
> connection and return a Connection object through a getConnection()
> static function?
> 
> It seems to me that the second is better although it takes a little more
> effort.
> 
> Any thoughts on that?
> 
> Thanks in advance,
> 
> C.F.
> 
> ---------------------------------------------------------------------
> 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 Best Practices

Posted by Thomas Hartwig <t....@itth.com>.
This might overwhelm you question, but it is worth: have a look at
Persistence Frameworks: Hibernate or similar.

C.F. Scheidecker Antunes wrote:
> Hello all,
> 
> In order to access a Database on my Model layer, which one is best?
> 
> 1) A DataSource declared on the struts-config.xml. Then get the
> DataSource on your code inside either your actions or business classes.
> 
> 2) Create a class that will load the database Driver ,establish the
> connection and return a Connection object through a getConnection()
> static function?
> 
> It seems to me that the second is better although it takes a little more
> effort.
> 
> Any thoughts on that?
> 
> Thanks in advance,
> 
> C.F.


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