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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:45:13+00:00 2026-05-26T10:45:13+00:00

I am using Java Netbeans 6.9.1. I have an Table Called Workers in JavaDB.

  • 0

I am using Java Netbeans 6.9.1. I have an Table Called Workers in JavaDB. I want to Display Names of Workers in to Combo box. I am using Combobox on JinternalFrame.

Thanks in advance..

try{
String host="jdbc:derby://localhost:1527/Employees";
String uName="admin";
String uPass="admin";
con=DriverManager.getConnection(host, uName, uPass);
stmt = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );
String sql= "SELECT FIRST_NAME FROM APP.Workers";
rs=stmt.executeQuery(sql);
 while (rs.next()) {
String s = rs.getString("FIRST_NAME");
jComboBox1.addItem(s.trim());  } }catch (SQLException err) { System.out.println(err.getMessage() );}      `
  • 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-05-26T10:45:13+00:00Added an answer on May 26, 2026 at 10:45 am

    You can populate a swing’s JComboBox using setModel() method. This outlines what you should have:

    String[] list = new String[10]; // for example
    int count = 0;
    while (rs.next()) {
        list[count] = rs.getString("FIRST_NAME");
        count++;
    }
    jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(list));
    

    setModel() has one parameter which is a DefaultListComboBoxModel object, and this object is initialized using an array of strings as a list of models.

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

Sidebar

Related Questions

greetings, today i have started to learn java using netbeans ide. i would like
I have created a GUI in Java using swings with the help of Netbeans
I have a Java web app using JDBC created in NetBeans deployed to Tomcat
I'm using Netbeans to develop a Java application and I want to create a
I want to create a little game in Java using Netbeans. For now I
I have a Netbeans Platform modular project, not a regular Java project. I want
I'm using NetBeans 6.9.1 on Mac OS X 10.6.4 with Java 1.6.0_22. I have
I have installed Netbeans on my Mac Os X and started develop using Java.
I have developed a project in Java using NetBeans 6.1. I need to add
I've been developing Java with Netbeans and have been using the Run command on

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.