multiple JComboBoxes using with JDBC

Ads
 

multiple JComboBoxes using with JDBC

how to use JComboBoxes with JDBC in java
View Answers

October 16, 2010 at 12:03 PM

Hi Friend,

Try the following code:

import java.awt.*;
import java.sql.*;
import javax.swing.*;
public class MultipleJCombo{

public MultipleJCombo(){
JFrame f = new JFrame("Frame in Java Swing");
JLabel label1=new JLabel("Qualification");
JLabel label2=new JLabel("Specialization");
JComboBox jc1=new JComboBox();
JComboBox jc2=new JComboBox();
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con =DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from user_details");
jc1.addItem("Select");
jc2.addItem("Select");
while(rs.next()){
jc1.addItem(rs.getString("qualification"));
jc2.addItem(rs.getString("specialization"));
}
}
catch(Exception e){
}
JPanel p=new JPanel(new GridLayout(2,2));
p.add(label1);
p.add(jc1);
p.add(label2);
p.add(jc2);
f.add(p);
f.setVisible(true);
f.pack();

}
public static void main(String[] args) throws Exception{
MultipleJCombo sf=new MultipleJCombo();
}
}

Thanks

Ads









Related Tutorials/Questions & Answers:
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Advertisements
using Blob in jdbc - JDBC
using Blob in jdbc  Hi, I got an Exception when i was trying to insert one image into oracle 10g database the exception is Exception in thread..."); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
Email to multiple recipients using jsp
Email to multiple recipients using jsp  Hi sir, Am a doing a project,in that i need to send email to multiple user at a time,the to address should enter manually its not not be written in code using jsp. Regards, Santhosh
Email to multiple recipients using jsp
Email to multiple recipients using jsp  Hi sir, Am a doing a project,in that i need to send email to multiple user at a time,the to address should enter manually its not not be written in code using jsp. Regards, Santhosh
delete multiple row using checkbox
delete multiple row using checkbox  delete multiple row using...("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc...("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc:mysql
Display Multiple Images in jscrollpane using Java Jpanel
Display Multiple Images in jscrollpane using Java Jpanel  Browse and Display multiple images in vertical view of java jscrollpane using jpanel
Multiple image upload using JSP
Multiple image upload using JSP  I have written a code to upload the multiple images using jsp, but when I execute this code, it throws Corrupt form... type="file" name="file[]" multiple > <INPUT type="submit" value="Send
Uploading Multiple Files Using Jsp
Uploading Multiple Files Using Jsp  ... to understand how you can upload multiple files by using the Jsp. We should avoid... a file. In this example we are going to tell you how we can upload multiple files
not able to connect to mysql using.. jdbc
not able to connect to mysql using.. jdbc   i am not able to connect to mysql using jdbc .. is there any classpath that i need to set..because i am using mysql-connector-java jar file..to connect to mysql.. Pls provide the steps
Storing Multiple image in sql using java
Storing Multiple image in sql using java  Hi, How to store and retrieve a multiple image in sql using java but already i have created sql table if i want to insert a image while runtime execution. Can anyone tell me solution
how to scroll multiple images using on Click in Android
how to scroll multiple images using on Click in Android  I am new... there is requirement like multiple image scrolling dynamically. But unfortunately i am unable to scroll multiple images. But i am able to scroll single image. plz let me know
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
inserting multiple file formats into database using html
inserting multiple file formats into database using html   hi the code was working fine,i want to choose the file and then upload to database,by using html.whether it is possible to upload larger file size,please explain
excel file using JDBC java.?
excel file using JDBC java.?  hey, i am a telecomm. engineer , and i am try to develop a tool which reads from a excel file and then appends the same... used JDBC ODBC to read from excel file. i am not able to append it using
Connecting to remote mysql server using jdbc.
Connecting to remote mysql server using jdbc.  How to Connect to remote mysql server using jdbc
Merge multiple jasper file to one word Doc using java
Merge multiple jasper file to one word Doc using java   how to Merge multiple jasper file to one word Doc using java
JDBC Transaction Example
. When  you create a connection using JDBC, by default it is in auto...JDBC Transaction Example JDBC Transaction  JDBC transaction is used... with instruction. How to manage transaction in JDBC? Then Write the Following
how can i achieve multiple inheritance in java without using inheritance ?
how can i achieve multiple inheritance in java without using inheritance ?  how can i achieve multiple inheritance in java without using inheritance
approve or reject multiple selected rows using check box
approve or reject multiple selected rows using check box   Select Article Document Type Document Sub Type
spring mvc configuration with mysql using jdbc
spring mvc configuration with mysql using jdbc  hai I want to configure web mvc with mysql using jdbc template. when I submit values using registration form it will reflect on database which i was created earlier. send me code
courier management service (using servlets,jsp,jdbc)
courier management service (using servlets,jsp,jdbc)   is anyone having information about courier management service ? plz share it .its urgent THANKING YOU IN ADVANCE
Multiple files upload code using spring mvc 2.0 with xml configuration without using annotations
Multiple files upload code using spring mvc 2.0 with xml configuration without using annotations  how to write code to attach multiple files and upload using spring mvc 2.o with xml configuration with out annotations? please
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?  HELLO SIR, CAN ANYONE HELP ME OUT HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML... HELP ME OUT WITH HOW TO VIEW THE STORED DATA IN XML FILE USING EMPNAME. PLEASE
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>... to upload the multiple images in struts Total images storing folder in project
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>... to upload the multiple images in struts Total images storing folder in project
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>... to upload the multiple images in struts Total images storing folder in project
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>... to upload the multiple images in struts Total images storing folder in project

Ads