You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ryan Cornia <rc...@dced.state.ut.us> on 2001/07/18 15:55:46 UTC

Where do YOU put JDBC calls?

I'm wondering what people are considering best practices for JDBC calls?

I have been writing beans that wrap a database table, and include functions "select", "insert", "delete". These functions either load the bean, insert the bean values in the database, or delete the record from the database. In all of these functions, I pass in a database connection from the action. (Or whatever else is calling the bean.)

ie- public boolean select(Connection cn1, String primaryKey)

How are others doing it? I think this is a good approach, but want to see if someone has come up with something better.

Thanks,
Ryan

Re: Where do YOU put JDBC calls?

Posted by Oleg V Alexeev <go...@penza.net>.
Hello Ryan,

Wednesday, July 18, 2001, 5:55:46 PM, you wrote:

RC> I'm wondering what people are considering best practices for JDBC calls?

RC> I have been writing beans that wrap a database table, and include functions "select", "insert", "delete". These functions either load the bean, insert the bean values in the database, or delete
RC> the record from the database. In all of these functions, I pass in a database connection from the action. (Or whatever else is calling the bean.)

RC> ie- public boolean select(Connection cn1, String primaryKey)

RC> How are others doing it? I think this is a good approach, but want to see if someone has come up with something better.

RC> Thanks,
RC> Ryan

Take a look to the jdbc-example in validator - it contains sample of
jdbc calls similar to Command pattern.

-- 
Best regards,
 Oleg                            mailto:gonza@penza.net