Results 1 to 6 of 6
Thread: Multiple combobox
- 11-29-2012, 06:36 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 5
- Rep Power
- 0
Multiple combobox
i have form to customer fill it out.
In that form, i have combobox which connect to my database to show product name.
If the customer have more than one product name, how can i make it?Java Code:teks=new JLabel("Car Name"); textPerintah=new JTextField(15); teks1=new JLabel("Car Number"); textPerintah1=new JTextField(15); teks2=new JLabel("Driver"); textPerintah2=new JTextField(15); teks3=new JLabel("Date :"); textPerintah3=new JTextField(15); teks4=new JLabel("Product Name :"); try { Class.forName("com.mysql.jdbc.Driver"); Connection connect=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root",""); Statement s=connect.createStatement(); String SQL=("SELECT product FROM storeproduct"); rs=s.executeQuery(SQL); while (rs.next()) { String product =rs.getString("product_name"); listBox.addItem(nama.trim()); } } catch (Exception e) { JOptionPane.showMessageDialog(null,"Failed to Connect to Database","Error Connection", JOptionPane.WARNING_MESSAGE); System.exit(0); } listBox.addActionListener(); teks5=new JLabel("Price"); textPerintah5=new JTextField(15);
Can anybody help me. Thanks Before....
- 11-29-2012, 07:10 AM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: Multiple combobox
You select the colums "product" in your storeproduct table, but wants the "product_name" at the getString method? That`s not matching...it seems to be one of them is wrong.
Have you debugged the code? Is the while loop entered?
Maybe you have to use (just a suspicion):
"SELECT product_name FROM storeproduct" ?
Or tell us more about your table!
- 11-29-2012, 08:28 AM #3
Member
- Join Date
- Nov 2012
- Posts
- 5
- Rep Power
- 0
Re: Multiple combobox
upss..sorry...
this is the correct code and i already debugged...
Can u help me, sir?Java Code:teks=new JLabel("Car Name"); textPerintah=new JTextField(15); teks1=new JLabel("Car Number"); textPerintah1=new JTextField(15); teks2=new JLabel("Driver"); textPerintah2=new JTextField(15); teks3=new JLabel("Date :"); textPerintah3=new JTextField(15); teks4=new JLabel("Product Name :"); try { Class.forName("com.mysql.jdbc.Driver"); Connection connect=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root",""); Statement s=connect.createStatement(); String SQL=("SELECT product FROM storeproduct"); rs=s.executeQuery(SQL); while (rs.next()) { String product =rs.getString("product"); listBox.addItem(nama.trim()); } } catch (Exception e) { JOptionPane.showMessageDialog(null,"Failed to Connect to Database","Error Connection", JOptionPane.WARNING_MESSAGE); System.exit(0); } listBox.addActionListener(); teks5=new JLabel("Price"); textPerintah5=new JTextField(15);
- 11-29-2012, 09:38 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Multiple combobox
Sorry, not sure what your problem is.
What should it be doing?
That code can't be compiling, surely?
I can see at least one error in there witht he addActionListener.Please do not ask for code as refusal often offends.
- 11-29-2012, 09:49 AM #5
Member
- Join Date
- Nov 2012
- Posts
- 5
- Rep Power
- 0
- 11-29-2012, 11:06 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
One process open multiple threads on multiple CPUs
By kfcnhl in forum Threads and SynchronizationReplies: 2Last Post: 12-12-2011, 08:27 AM -
How to create Multiple Combobox Vertically.
By Khan05 in forum New To JavaReplies: 6Last Post: 08-06-2011, 07:54 AM -
multiple Data from Jsp that having same name of multiple input tage to servlet
By rahul9323.2007@gmail.com in forum Advanced JavaReplies: 0Last Post: 07-29-2011, 01:00 PM -
combobox
By dina in forum AWT / SwingReplies: 7Last Post: 05-11-2011, 05:31 PM -
Multiple ComboBox - Reading Text
By jorgelex008 in forum AWT / SwingReplies: 6Last Post: 01-04-2010, 11:27 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks