struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Mercer <>
Subject Accessing Database Information
Date Sun, 30 Jan 2005 16:02:15 GMT
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 

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 ( {
        atnlist = new BillpayForm();
    } finally {
            if (rs != null) {
            if (stmt != null) {
            if (conn != null) {

    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.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message