473,326 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

adding items in jcombobox

56
Expand|Select|Wrap|Line Numbers
  1.     private void pnosActionPerformed(java.awt.event.ActionEvent evt) {
  2.  
  3.        try { 
  4.              Class.forName("com.mysql.jdbc.Driver");
  5.             try (Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/depatment", "root","riham00879")) {
  6.                 Statement statement = connection.createStatement();
  7.                 String query = "SELECT * FROM protocol";
  8.                 ResultSet rs = statement.executeQuery(query);
  9.  
  10.                 while (rs.next())
  11.                 {      
  12.                    String pno = rs.getString("pno");         
  13.                   pnos.addItem("pno");
  14.                       System.out.println(pno);
  15.                 }
  16.             }
  17.              } catch (ClassNotFoundException | SQLException e) {
  18.              }
  19.  
  20.     }
i am trying to get data from MySQL database and print it in the jcombobox but nothing is printed
what is the problem ??
Feb 6 '14 #1
2 1411
Nepomuk
3,112 Expert 2GB
I'm no expert in the MySQL stuff but I see you're using System.out.println(pno); is this how you're trying to set the contents of the jcombobox? Because that won't work; that will only print the value of pno to the standard output, which is probably a console. What you want to use is JComboBox.addItem(...) to add something to the JComboBox.
Feb 6 '14 #2
Norgy
56
i tried to write -> pnos.addItem(pno);
and removed the line of System.out.println
but the problem hasn't resolved yet
Feb 6 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: R.G. Vervoort | last post by:
Not sure if it is a php question but since i am working in php here it is. Ho can i add items to (the item label=visual text and the value=index number) a list object on a website. I am having...
2
by: R.G. Vervoort | last post by:
Ho can i add items to (the item label=visual text and the value=index number) a list object on a website. I am having a list with 4 items and i would like to add the text from a textfield...
2
by: cybertof | last post by:
Hello, Is there a solution to the following problem : When filling a listview (30 columns) with around 5000 items, it can take easily 10 sec for the listview to be filled. I have used...
3
by: Holmes | last post by:
Hello Ran into a bit of a problem here and have now exhausted my resources to getting this working What I am trying to do is load and show a simple vb form with a listbox in it Dim...
20
by: Ash Phillips | last post by:
Hi Everyone, I have this program I wrote in VB6 for family use. It's a DVD Database just for me to keep track of them cause I have so many lol. In VB6, I could add items to the ListView in...
6
by: Papa.Coen | last post by:
I've just spend a lot of time solving the following problem: I used dotNet 2.0 / Visualstudio 2005 / C# / aspx, enable viewstate is set on all controls. I have 2 listboxes; the left contains items...
6
by: mrmagoo | last post by:
I'm trying to add an object to a listbox. I'm using a DataReader from a resultset from a stored procedure. It works except when there are NULL in any of the rows. Then I get an error: An...
1
by: bill | last post by:
I need to be able to dynamically add items to a <asp:listbox> (or HTML <select runat=server>) using clientside javascript, and retrieve the items when the page is posted back. I use this code to...
2
by: =?Utf-8?B?TWFobW91ZCBTaGFiYW4=?= | last post by:
i have a problem in adding new listbox items i don't need to allow adding multible items with the same textvalue ex: if current items are: green red
0
by: Steve K. | last post by:
I understand the concepts and rules for invoking UI methods from a non-UI thread. In the past I have always checked with the control's InvokeRequired property and Invoked my delegate accordingly. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.