I've got Ted Husted's book Struts in Action and I really like it. I've also got another book Professional Jakarta Struts. They both talk about accessing information from a database and DAO and DTO and all that jazz and quite frankly I don't understand it. :-P Right now I'm in the middle of this rather sophisticated application and I'm starting to wonder if I could be doing things a lot more easily. For instance, when I retrieve information from a Database I do something like this in my action:
ArrayList results = BillpayData.getAssets( account, getDataSource(request, "transactions"));
And I have the BillpayData class to handle getting the information from the DB and set it into a bean like:
public class BillpayData {
public static ArrayList getAssets( final String account, final DataSource dataSource) throws Exception {
Connection conn = null; Statement stmt = null; ResultSet rs = null; BillpayForm atnlist = null; ArrayList result = new ArrayList();
try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(
"select * from assets where account=\"" + account + "\"");
// While there are results from our query
// create the codes bean with the proper
// values from the database.
while (rs.next()) {
atnlist = new BillpayForm();
atnlist.setAtn(rs.getString("atn"));
atnlist.setDescription(rs.getString("description"));
result.add(atnlist);
}
} finally {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
}
return result;
}
}
BUT... I see all these handy examples about setting that stuff in a bean using beanutils and it makes me think I'm doign way too much work! Does anyone have an explination of what Data Access Object structure I should be using (or is the way I'm doing things ok)? And does anyone have any simple applications that show a good way to use those beanutils (as I'm not very good with java just yet). Thanks for your help.
Brandon
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]