Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7829187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:39:44+00:00 2026-06-02T10:39:44+00:00

I have a custom an arraylist setup to hold data for me. However when

  • 0

I have a custom an arraylist setup to hold data for me.
However when I call the arraylist items all the items are the same.

My arraylist loader.

public static ArrayList<Animal> 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<Animal> alAnimals = new ArrayList<Animal>();

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

Animal Constructor

public Animal(int intAnimal_ID) throws Exception{
    CC_H2 db = new CC_H2();
    db.Connect(Variables.getStrConn(), "admin", "", "Embedded");
    ResultSet rs = db.query("Select * FROM tblHerd WHERE HERD_ID = "
            + intAnimal_ID);
    while (rs.next()) {
        setIntHerd_id(rs.getInt("Herd_ID"));
        setStrHerd_Tag_Letter(rs.getString("Herd_Tag_Letter"));
        setIntHerd_Tag_Num(rs.getInt("Herd_Tag_Num"));
        setStrHerd_Tag_Color(rs.getString("Herd_Tag_Color"));
        setStrHerd_Sex(rs.getString("Herd_Sex"));
        setStrHerd_Type(rs.getString("Herd_Type"));
        setDtHerd_Birthdate(rs.getDate("Herd_Birthdate"));
        setIntHerd_Sire(rs.getInt("Herd_Sire"));
        setIntHerd_Dam(rs.getInt("Herd_Dam"));
        setIntHerd_Owner(rs.getInt("Herd_Owner"));
        setDtHerd_TimeStamp(rs.getDate("Herd_TimeStamp"));
        setStrHerd_Status(rs.getString("Herd_Status"));
        setDtHerd_Status_Date(rs.getDate("Herd_Status_Date"));
    }
    db.Disconnect();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:39:47+00:00Added an answer on June 2, 2026 at 10:39 am

    I think the code you listed should work as expected, the error is probably somewhere else.

    • Check the data in your database
    • Check the setters in the while loop do the right thing
    • Check that the fields in the Animal class are not static
    • If the problem persists, try to put something like System.out.println(rs.getInt("Herd_ID") + ": " + rs.getString("Herd_Tag_Letter")); into the where loop and check the output

    Hope some of this helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ArrayList of items that are linked to a custom Adapter. The
I have an h:dataTable with data generated from an ArrayList with custom object Result.
I have an arraylist with a custom object type named StartsideElement. <c:forEach items=#{startsideClient.brukerelementer} var=element
I have a custom class CurvePoint which I define a set of data items
I have custom event that has several different subscribers who will all use the
I have custom gallery. Gallery represents items that are frame layout. There are one
I have a custom Android ContentProvider which stores and retrieves data from a SQLite
I have made a custom adapter class here is the code public class CustomArrayAdapterForReceipts
I have created an ArrayList (Java) of my custom class objects with a size
I have created an arraylist that is made up of custom objects. Basically the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.