Populating a Combo Box with Data using a DAL2019 Community Moderator ElectionFastest way to determine if an integer's square root is an integerWhy can't I define a static method in a Java interface?Data Access Layer (DAL) designEfficiency of Java “Double Brace Initialization”?How to call getClass() from a static method in Java?Separation of business logic and data access in djangoWrapped image not displaying in combo boxConverting between java.time.LocalDateTime and java.util.DatePopulating a combo box from MS Access DatabaseC# populate a combo box from a method

What can I do if someone tampers with my SSH public key?

Will expression retain the same definition if particle is changed?

I can't die. Who am I?

How do you make a gun that shoots melee weapons and/or swords?

Traveling to heavily polluted city, what practical measures can I take to minimize impact?

Is it a Cyclops number? "Nobody" knows!

Is there a logarithm base for which the logarithm becomes an identity function?

Leveling the sagging side of the home

How can a demon take control of a human body during REM sleep?

What should I do when a paper is published similar to my PhD thesis without citation?

Movie: boy escapes the real world and goes to a fantasy world with big furry trolls

How to install round brake pads

Is "cogitate" used appropriately in "I cogitate that success relies on hard work"?

Does an unused member variable take up memory?

Is this Paypal Github SDK reference really a dangerous site?

Can the Witch Sight warlock invocation see through the Mirror Image spell?

Having the player face themselves after the mid-game

Help! My Character is too much for her story!

Is it appropriate to ask a former professor to order a book for me through an inter-library loan?

What do you call someone who likes to pick fights?

How should I solve this integral with changing parameters?

What is the purpose of a disclaimer like "this is not legal advice"?

"If + would" conditional in present perfect tense

How to copy the rest of lines of a file to another file



Populating a Combo Box with Data using a DAL



2019 Community Moderator ElectionFastest way to determine if an integer's square root is an integerWhy can't I define a static method in a Java interface?Data Access Layer (DAL) designEfficiency of Java “Double Brace Initialization”?How to call getClass() from a static method in Java?Separation of business logic and data access in djangoWrapped image not displaying in combo boxConverting between java.time.LocalDateTime and java.util.DatePopulating a combo box from MS Access DatabaseC# populate a combo box from a method










-1















I am using a DAL and I am trying to populate a ComboBox with data from the DAL.



I am aware of how to do this when I am connecting to the database directly from the GUI code, however I am trying to use Classes so that I do not need to reconnect to the database every time I make a new method in the GUI code.



I use NetBeans IDE, is there a way to do this?










share|improve this question







New contributor




Nico Cruickshank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • This DAO uses JDBC?

    – tomrlh
    Mar 6 at 23:36











  • Yes, It uses JDBC

    – Nico Cruickshank
    Mar 6 at 23:38











  • Show us your combobox GUI code, if possible

    – tomrlh
    Mar 6 at 23:39















-1















I am using a DAL and I am trying to populate a ComboBox with data from the DAL.



I am aware of how to do this when I am connecting to the database directly from the GUI code, however I am trying to use Classes so that I do not need to reconnect to the database every time I make a new method in the GUI code.



I use NetBeans IDE, is there a way to do this?










share|improve this question







New contributor




Nico Cruickshank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • This DAO uses JDBC?

    – tomrlh
    Mar 6 at 23:36











  • Yes, It uses JDBC

    – Nico Cruickshank
    Mar 6 at 23:38











  • Show us your combobox GUI code, if possible

    – tomrlh
    Mar 6 at 23:39













-1












-1








-1








I am using a DAL and I am trying to populate a ComboBox with data from the DAL.



I am aware of how to do this when I am connecting to the database directly from the GUI code, however I am trying to use Classes so that I do not need to reconnect to the database every time I make a new method in the GUI code.



I use NetBeans IDE, is there a way to do this?










share|improve this question







New contributor




Nico Cruickshank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I am using a DAL and I am trying to populate a ComboBox with data from the DAL.



I am aware of how to do this when I am connecting to the database directly from the GUI code, however I am trying to use Classes so that I do not need to reconnect to the database every time I make a new method in the GUI code.



I use NetBeans IDE, is there a way to do this?







java combobox dao data-access-layer






share|improve this question







New contributor




Nico Cruickshank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Nico Cruickshank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Nico Cruickshank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 6 at 23:01









Nico CruickshankNico Cruickshank

11




11




New contributor




Nico Cruickshank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Nico Cruickshank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Nico Cruickshank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • This DAO uses JDBC?

    – tomrlh
    Mar 6 at 23:36











  • Yes, It uses JDBC

    – Nico Cruickshank
    Mar 6 at 23:38











  • Show us your combobox GUI code, if possible

    – tomrlh
    Mar 6 at 23:39

















  • This DAO uses JDBC?

    – tomrlh
    Mar 6 at 23:36











  • Yes, It uses JDBC

    – Nico Cruickshank
    Mar 6 at 23:38











  • Show us your combobox GUI code, if possible

    – tomrlh
    Mar 6 at 23:39
















This DAO uses JDBC?

– tomrlh
Mar 6 at 23:36





This DAO uses JDBC?

– tomrlh
Mar 6 at 23:36













Yes, It uses JDBC

– Nico Cruickshank
Mar 6 at 23:38





Yes, It uses JDBC

– Nico Cruickshank
Mar 6 at 23:38













Show us your combobox GUI code, if possible

– tomrlh
Mar 6 at 23:39





Show us your combobox GUI code, if possible

– tomrlh
Mar 6 at 23:39












1 Answer
1






active

oldest

votes


















0














Welcome to Stack Overflow.



In the constructor, or whenever you fill your combobox, you will get the data from the database with a query:



Statement statement = dbConnection.createStatement();
ResultSet rs = statement.executeQuery("SELECT name FROM users"); // a query example, you will replace it with the query you need
List<String> comboContent = new ArrayList<>();

while (rs.next())
comboContent.add(rs.getString("name"); // get content by column name



And in your JComboBox you will add the result in it's construction:



JComboBox myCombo = new JComboBox(comboContent.asList());






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Nico Cruickshank is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55033578%2fpopulating-a-combo-box-with-data-using-a-dal%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Welcome to Stack Overflow.



    In the constructor, or whenever you fill your combobox, you will get the data from the database with a query:



    Statement statement = dbConnection.createStatement();
    ResultSet rs = statement.executeQuery("SELECT name FROM users"); // a query example, you will replace it with the query you need
    List<String> comboContent = new ArrayList<>();

    while (rs.next())
    comboContent.add(rs.getString("name"); // get content by column name



    And in your JComboBox you will add the result in it's construction:



    JComboBox myCombo = new JComboBox(comboContent.asList());






    share|improve this answer



























      0














      Welcome to Stack Overflow.



      In the constructor, or whenever you fill your combobox, you will get the data from the database with a query:



      Statement statement = dbConnection.createStatement();
      ResultSet rs = statement.executeQuery("SELECT name FROM users"); // a query example, you will replace it with the query you need
      List<String> comboContent = new ArrayList<>();

      while (rs.next())
      comboContent.add(rs.getString("name"); // get content by column name



      And in your JComboBox you will add the result in it's construction:



      JComboBox myCombo = new JComboBox(comboContent.asList());






      share|improve this answer

























        0












        0








        0







        Welcome to Stack Overflow.



        In the constructor, or whenever you fill your combobox, you will get the data from the database with a query:



        Statement statement = dbConnection.createStatement();
        ResultSet rs = statement.executeQuery("SELECT name FROM users"); // a query example, you will replace it with the query you need
        List<String> comboContent = new ArrayList<>();

        while (rs.next())
        comboContent.add(rs.getString("name"); // get content by column name



        And in your JComboBox you will add the result in it's construction:



        JComboBox myCombo = new JComboBox(comboContent.asList());






        share|improve this answer













        Welcome to Stack Overflow.



        In the constructor, or whenever you fill your combobox, you will get the data from the database with a query:



        Statement statement = dbConnection.createStatement();
        ResultSet rs = statement.executeQuery("SELECT name FROM users"); // a query example, you will replace it with the query you need
        List<String> comboContent = new ArrayList<>();

        while (rs.next())
        comboContent.add(rs.getString("name"); // get content by column name



        And in your JComboBox you will add the result in it's construction:



        JComboBox myCombo = new JComboBox(comboContent.asList());







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 6 at 23:58









        tomrlhtomrlh

        517622




        517622






















            Nico Cruickshank is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Nico Cruickshank is a new contributor. Be nice, and check out our Code of Conduct.












            Nico Cruickshank is a new contributor. Be nice, and check out our Code of Conduct.











            Nico Cruickshank is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55033578%2fpopulating-a-combo-box-with-data-using-a-dal%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived