I would say: 3) Create a class that will look up the DataSource via JNDI lookup and cache that reference during initialization, and use that reference to get connections to distribute in your getConnection method. Only if the DataSource (aka connection pool) fails or is turned off would you need to get connections directly from DriverManager in your getConnection method.
This is really the same as #1 except that you are not involving Struts (because it doesn't need to be involved), and you don't pass around the DataSource, you just pass around the connections it provides. Don't forget to implement cleanup or releaseConnection, too. Erik -----Original Message----- From: "C.F. Scheidecker Antunes" <[EMAIL PROTECTED]> Sent: Aug 17, 2005 9:22 PM To: Struts Users Mailing List <user@struts.apache.org> Subject: 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]