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 8103437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:32:58+00:00 2026-06-05T23:32:58+00:00

I have a MySQL database which contains data i would like to populate into

  • 0

I have a MySQL database which contains data i would like to populate into a JList in my java program. I have two JList, one which is fill with Events Title and the second is to be fill with Guest Name.

What i would like is when the user click on any of the Events Title, the second JList will show all the Guest Name that belong to that Event.

I have already successfully populate the first JList with all the Events Title. What I’m having trouble with is when the user click on the Events Title, the Guests Name will show twice on the second JList. How can i make it to show only once?

Here is what i got so far…

Java Class

private JList getJListEvents() {
    if (jListEvents == null) {
        jListEvents = new JList();
        Border border = BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(1, Color.black, Color.black), "Events", TitledBorder.LEFT, TitledBorder.TOP);
        jListEvents.setBorder(border);
        jListEvents.setModel(new DefaultListModel());
        jListEvents.setBounds(new Rectangle(15, 60, 361, 421));

        Events lEvents = new Events();
        lEvents.loadEvents(jListEvents);

        jListEvents.addListSelectionListener(new ListSelectionListener(){
            public void valueChanged(ListSelectionEvent e){
                EventC eventC = new EventC();
                //eventC.MonitorRegDetailsInfo(jListEvents, jTextFieldEventName, jTextFieldEventVenue, jTextFieldEventDate, jTextFieldEventTime, jTextAreaEventDesc);
                //eventC.MonitorRegPackageInfo(jListEvents, jTextFieldBallroom, jTextFieldBallroomPrice, jTextFieldMeal, jTextFieldMealPrice, jTextFieldEntertainment, jTextFieldEntertainmentPrice);
                eventC.MonitorRegGuest(jListEvents, jListGuest);
            }
        });
    }
    return jListEvents;
}

Controller Class

public void MonitorRegGuest(JList l, JList l2){
    String event = l.getSelectedValue().toString();
    Events retrieveGuest = new Events(event);
    retrieveGuest.loadGuests(l2);
}

Class with all the sql statement

public void loadGuests(JList l){
    ResultSet rs = null;
    ResultSet rs2 = null;
    ResultSet rs3 = null;
    MySQLController db = new MySQLController();
    db.getConnection();

    String sqlQuery = "SELECT MemberID FROM event WHERE EventName = '" + EventName + "'";
    try {
        rs = db.readRequest(sqlQuery);
        while(rs.next()){
            MemberID = rs.getString("MemberID");
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }

    String sqlQuery2 = "SELECT GuestListID FROM guestlist WHERE MemberID = '" + MemberID + "'";
    try {
        rs2 = db.readRequest(sqlQuery2);
        while(rs2.next()){
            GuestListID = rs2.getString("GuestListID");
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }

    String sqlQuery3 = "SELECT Name FROM guestcontact WHERE GuestListID = '" + GuestListID + "'";
    try {
        rs3 = db.readRequest(sqlQuery3);
        while(rs3.next()){
            ((DefaultListModel)l.getModel()).addElement(rs3.getString("Name"));
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    db.terminate();
}

Thanks in advance!

  • 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-05T23:33:00+00:00Added an answer on June 5, 2026 at 11:33 pm

    Please for the time being forget about the SQL. Then follow the steps below:

    1. Start with the example — the corresponding Java Web Start link.
    2. Play with the sample, to see how to add elements to a list.
    3. Then all you need to do is grab a reference to the one you want to copy and for each element copy it then add to the 2nd list.
    4. Enjoy Java.

    EDIT:
    I am still looking at your code and I am still confused of what is going on (Please consider making a SSCCE). But let me guess, as something is telling me that when you are calling the ListSelectionListener you are not using getIsValueAdjusting() of the ListSelectionEvent, right? Therefore, this might be as well it, for more read here.

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

Sidebar

Related Questions

i have a large mysql database table in which one column contains values ranging
I have a database that has two tables, one of which contains a foreign
I have a mysql database with which contains data in 5 minute bins. I'd
I have a mysql database which as one of the fields contains a html
I have table which contains double values stored in mysql database ...I need to
Greetings friends, In my MySQL database, I have 'MAB' table which contains information about
I have MySQL database, where I store the following BLOB (which contains JSON object)
I have a table with a field which contains strings in my MySQL database.
I have a xml file which contains data I want to insert into a
I currently have a MySQL database which I was hoping to use to store

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.