Should I Move Methods To A Different Class The following code is part a class called class db_tables. All the other getTbl* methods other than getTblHerd pull information based on the ID of the animal that is passed to them.

My question is while the following code works would it be better to move all the other getTbl methods into the Animal class and pass them the ID stored in the Animal class.

Thanks,

public static ArrayList&lt;Animal&gt; getTblHerd() throws Exception {
    CC_H2 db = new CC_H2();
    db.Connect(Variables.getStrConn(), Variables.getStrUser(),
            Variables.getStrPassword(), "Embedded");
    ResultSet rs = db
            .query("Select HERD_ID FROM tblHerd ORDER BY HERD_ID ASC");

    ArrayList&lt;Animal&gt; alAnimals = new ArrayList&lt;Animal&gt;();

    while (rs.next()) {
        int i = rs.getInt("HERD_ID");
        alAnimals.add(new Animal(i));
    }
    db.Disconnect();
    return alAnimals;
}

public static ArrayList&lt;Note&gt; getTblNotes(int intID) throws Exception {
    CC_H2 db = new CC_H2();
    db.Connect(Variables.getStrConn(), Variables.getStrUser(),
            Variables.getStrPassword(), "Embedded");
    ResultSet rs = db
            .query("Select NOTE_ID FROM tblNotes WHERE NOTE_HERD_ID = "
                    + intID + " ORDER BY Note_Date DESC");

    ArrayList&lt;Note&gt; alNotes = new ArrayList&lt;Note&gt;();

    while (rs.next()) {
        int i = rs.getInt("NOTE_ID");
        alNotes.add(new Note(i));
    }
    db.Disconnect();
    return alNotes;
}

public static ArrayList&lt;Vaccination&gt; getTblVaccination(int intID) throws Exception {
    CC_H2 db = new CC_H2();
    db.Connect(Variables.getStrConn(), Variables.getStrUser(),
            Variables.getStrPassword(), "Embedded");
    ResultSet rs = db
            .query("Select Vac_ID FROM tblVaccination WHERE VAC_HERD_ID = "
                    + intID + " ORDER BY Vac_Date DESC");

    ArrayList&lt;Vaccination&gt; alVaccinations = new ArrayList&lt;Vaccination&gt;();

    while (rs.next()) {
        int i = rs.getInt("VAC_ID");
        alVaccinations.add(new Vaccination(i));
    }
    db.Disconnect();
    return alVaccinations;
}

public static ArrayList&lt;Owner&gt; getTblOwners(int intID) throws Exception {
    CC_H2 db = new CC_H2();
    db.Connect(Variables.getStrConn(), Variables.getStrUser(),
            Variables.getStrPassword(), "Embedded");
    ResultSet rs = db
            .query("Select Owner_ID FROM tblOwners WHERE Owner_ID = "
                    + intID + " ORDER BY Owner_Last_Name ASC");

    ArrayList&lt;Owner&gt; alOwners = new ArrayList&lt;Owner&gt;();

    while (rs.next()) {
        int i = rs.getInt("Owner_ID");
        alOwners.add(new Owner(i));
    }
    db.Disconnect();
    return alOwners;
}
Well, Your code looks good, and your suspicion seems right. I would agree with you. My reasoning is that your objects should be modeled after the problem rather than the data base schema. Here I would say that the other getTbl* methods are actually getters on particular animals. So it makes sense to move them to Animal class and rename the getTbl* methods accordingly, i.e getAnimalVaccinationList.

I would also recommend to refactor all these methods so that the db connect, and processing are in a different method,

public static ArrayList&lt;Integer&gt; runDbQuery(String query, String field) throws DbException {
    try {
      CC_H2 db = new CC_H2();
      db.Connect(Variables.getStrConn(), Variables.getStrUser(),
            Variables.getStrPassword(), "Embedded");
      ResultSet rs = db.query(query);
      ArrayList&lt;Integer&gt; lst = new ArrayList&lt;Integer&gt;();
      while (rs.next()) {
        lst.add(new Vaccination(rs.getInt(field)));
      }
      db.Disconnect();
      return lst;
    } catch(SpecificException e) {
      // Do not throw exception, process the exception and throw
      // some thing relevant to your program.
      throw new DbException(e);
    }
}


and use this in other methods to avoid repetition. I would also recommend moving the getTblHerd to another class - say Herd because it has an independent identity other than db_tables.

Here is an example of using the above method

public static ArrayList&lt;Note&gt; getTblNotes(int intID) throws DbException {
    String query = "Select NOTE_ID FROM tblNotes WHERE NOTE_HERD_ID = "
                    + intID + " ORDER BY Note_Date DESC";

    ArrayList&lt;Note&gt; alNotes = new ArrayList&lt;Note&gt;();
    for (Integer i : runQuery(query, "NOTE_ID")) { 
        alNotes.add(new Note(i));
    }
    return alNotes;
}