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
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
New contributor
add a comment |
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
New contributor
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
add a comment |
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
New contributor
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
java combobox dao data-access-layer
New contributor
New contributor
New contributor
asked Mar 6 at 23:01
Nico CruickshankNico Cruickshank
11
11
New contributor
New contributor
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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());
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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());
add a comment |
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());
add a comment |
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());
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());
answered Mar 6 at 23:58
tomrlhtomrlh
517622
517622
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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