How to save JCombobox Selected Item in to Access Database

How to save JCombobox Selected Item in to Access Database

How to save JCombobox Selected Item in to Access Database
View Answers

April 10, 2010 at 11:05 AM

Hi Friend,

Try the following code:

import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SwingFrame{
public static void main(String[] args) throws Exception{
SwingFrame sf=new SwingFrame();
}
public SwingFrame(){
JFrame f = new JFrame("Frame in Java Swing");
f.getContentPane().setLayout(null);
JLabel lbl1=new JLabel("Branch");
final JComboBox jc=new JComboBox();
JButton b=new JButton("Insert");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select name from course");

jc.addItem("Select");
while(rs.next()){
jc.addItem(rs.getString("name"));
}
}
catch(Exception e){}
lbl1.setBounds(100,120,70,20);

jc.setBounds(170,120,100,20);
b.setBounds(170,150,100,20);
f.add(lbl1);

f.add(b);
f.add(jc);
f.setSize(1000,1000);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){

String st= jc.getSelectedItem().toString();
System.out.println(st);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement stmt=con.createStatement();
int i=stmt.executeUpdate("insert into Student(Course) values('"+st+"')");
}
catch(Exception ex){
System.out.println(ex);
}
}
});
}
}

Thanks









Related Tutorials/Questions & Answers:
How to save JCombobox Selected Item in to Access Database - Java Beginners
How to save JCombobox Selected Item in to Access Database  How to save JCombobox Selected Item in to Access Database  Hi Friend, Try...().setLayout(null); JLabel lbl1=new JLabel("Branch"); final JComboBox jc=new
How to store JComboBox selected Item into Ms Access Database - Java Beginners
How to store JComboBox selected Item into Ms Access Database  How to store JComboBox selected Item into Ms Access Database.  Hi Friend..."); f.getContentPane().setLayout(null); JLabel lbl1=new JLabel("Branch"); final JComboBox jc
Advertisements
How to store JComboBox item into database
How to store JComboBox item into database   import...(javax.swing.SwingConstants.CENTER); jLabel2.setText("Item Code"); getContentPane().add(jLabel2,new...); jLabel3.setText("Item Name"); getContentPane().add(jLabel3,new AbsoluteConstraints(27
Java JComboBox Get Selected Item Value
Java JComboBox Get Selected Item Value In this section we will discuss about how to get the selected item value form JComboBox. javax.swing.JComboBox... of JComboBox into the database table. To store the selected item value of JComboBox
How to save Selected text of RadioButton in to Access Databse - Java Beginners
How to save Selected text of RadioButton in to Access Databse  Sir I wnt To store Selected JRadioButton Text in to access Database plz Help Me Sir. and how to link website in to our Java Application with JRadioButton. 
navigation between panels when item is selected from jcombobox - Swing AWT
navigation between panels when item is selected from jcombobox  hi...(2nd panel).the combo box is in main panel. when a item is selected from combobox the 2nd panel should navigate to other panel. for now i have 4 item in the combo
how to insert the selected item of combobox in mysql - XML
how to insert the selected item of combobox in mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
Add Items in JComboBox from Access Database - Java Beginners
Add Items in JComboBox from Access Database  Heelo Sir I want To add ittem in JComboBox which is stored in Access Database. plz Help Me Sir Database Column name -Course Items -MBA,MCA,MBA IT,MBA FINANCE I want Load Database
How to search the selected item in row table using radia button in JSP?
How to search the selected item in row table using radia button in JSP?  How to search the selected item in row table using radia button in JSP
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database - Java Beginners
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database  Hello Sir I want Store Corse Type that contains Two JRadioButton I want Store Information from JRadioButton to MS Access Database, and I
Access 2007 database connectivity
Access 2007 database connectivity  i design an application form that have two JComboBox as the label(source,destination) and two JButton save and Exit. when i click at SAVE Button than it doesn't save the selected item from
Help on database and JComboBox
Help on database and JComboBox  I want to select from the JComboBox and when click onto the "search" button, the selected category (example "new york") all the each new york picture and detail will be seen. But how to grab
jComboBox with database
my database. But in my code its only get data from first item which...jComboBox with database  Hello friends, I have created three JComboBoxes. first two of them get list from string. However I select these two
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.  The code for retrieving data from database into Drop Down List. <% DataSource data = new
Link To Database with JComboBox - Java Beginners
Link To Database with JComboBox  sir As ur Source Code i have Load course names from Access Database in to JComboBox but now I want to do ,when i select Course name from Jcombobox i want to display appropriate records relate
how to access database in applet
how to access database in applet  HI... I'm having an applet where we should display the database values in the applet... It works fine in the local system(same network)... but when its in the server, we r getting null values
How to access the database from JSP?
How to access the database from JSP?  Hi, What is the process... database from JSP which explains you how to access the database by embedding... you can access the database by embedding the JDBC code. But this is not the best
nested selected tag ihave display selected item
nested selected tag ihave display selected item   i have two combo boxes combo1 combo1 in first combo box i taken as follows select name="combo1"> option value="0">-select- option value="1">INDIA option value
delete an item from database
delete an item from database  how to delete an item from the database using jsp
JComboBox
JComboBox  I have jcombobox. In which tha values are loaded from MySql Database. My problem is that i want to load content of the jtable whenever i change the selected item. Please some one help me to do this. Thank you
show null point Exception """ while trying 2 load a JComboBox"" data is fetch from database ms-access
show null point Exception """ while trying 2 load a JComboBox"" data is fetch from database ms-access  import javax.swing.*; import java.awt.*; import java.sql.*; class Comboo extends JFrame { JComboBox jcb; Connection con
show null point Exception """ while trying 2 load a JComboBox"" data is fetch from database ms-access
show null point Exception """ while trying 2 load a JComboBox"" data is fetch from database ms-access  import javax.swing.*; import java.awt.*; import java.sql.*; class Comboo extends JFrame { JComboBox jcb; Connection con
show null point Exception """ while trying 2 load a JComboBox"" data is fetch from database ms-access
show null point Exception """ while trying 2 load a JComboBox"" data is fetch from database ms-access  import javax.swing.*; import java.awt.*; import java.sql.*; class Comboo extends JFrame { JComboBox jcb; Connection con
how to access the MS ACCESS database with java
how to access the MS ACCESS database with java   how to access the MS ACCESS database with java how can we insert,delete,update,search records of ms access with java   Java MS Access database connectivity Follow
How to save database data into excelsheet using hibernate
How to save database data into excelsheet using hibernate  How to save database data into excelsheet using hibernate
Database values in JComboBox
Database values in JComboBox In this section, you will learn how to display values in JComboBox from database. For this, we have allowed the user to enter... the database will get displayed on the ComboBox. If there will be  no data
how to access the MS ACCESS database with java - Java Beginners
how to access the MS ACCESS database with java  how can we insert,delete,update,search records of ms access with java
how to save uploaded image in database using javascript
how to save uploaded image in database using javascript  Please can you tell me how to store uploaded image in database using java I'll use...; Now i want to store it on database...ADS_TO_REPLACE_1 Please help me Thanks
how to import excel sheet into mysql database and save it as a table in database
how to import excel sheet into mysql database and save it as a table in database  sir, i want to import an excel sheet into a MySQL database and after importing it i want to store the excel sheet as a table in database
How to obtain the selected data item from a list box when listbox contains objects wrapped under Arraylist?
How to obtain the selected data item from a list box when listbox contains objects wrapped under Arraylist?  I have a jsp page containing a list box... want to copy the selected item(one at a time) from the list box to the text box. I
How to access (MySQL)database from J2ME?
How to access (MySQL)database from J2ME?  I am new to J2ME. I am using NetBeans. Can anyone help me? How to access (MySQL)database from J2ME? ( I search a lot I found that there is need to access database through servlet
how to delete the access database value in jsp
how to delete the access database value in jsp  i loaded my database data into the dropdown list box...now i want to delete the value..plz send the source code to delete the value in dropdown list box and also from database
how to delete the access database value in jsp
how to delete the access database value in jsp  i loaded my database data into the dropdown list box...now i want to delete the value..plz send the source code to delete the value in dropdown list box and also from database
JComboBox
have jcombobox on Jframe form of IDE. In which the values are to be loaded from MySql Database. My problem is that i want to load content of the jtable whenever i change the selected item in JComboBox. Thank you. (adsbygoogle
how to update combobx's selected value to database with respect toselected multiple checkboxes
how to update combobx's selected value to database with respect toselected... to display records from database out.println("<tr><td>"+"<input type... values which is selected from form1.jsp String languages=""; String box
how to make drop down list in JSF & fetch data Item from database
how to make drop down list in JSF & fetch data Item from database  how to make drop down list in JSF & fetch data Item from database
how to connect to MS access database in JSP?
how to connect to MS access database in JSP?  how to connect to MS access database in JSP? Any seetings/drivers need to be set or installed before... and select the driver Microsoft Access Driver(*.mdb). 3)After selecting the driver
pbml in inserting selected item from combobox into mysql - XML
pbml in inserting selected item from combobox into mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
How To Connect MS ACCESS 2003 Database in C Program with Graphics.
How To Connect MS ACCESS 2003 Database in C Program with Graphics.  How To Connect MS ACCESS 2003 Database in C Program with Graphics
How to save form fields into the MySql Database without submit button in jsp?
How to save form fields into the MySql Database without submit button in jsp?  I want to store user inputs into the database using javasccript or ajax or jqury but without submit button. Form Contains three fields
How save,get picture from database in my jsp page?
How save,get picture from database in my jsp page?  How i save picture in db after browsing it,and also how i get it on my other jsp page
How i upload file and save that record in database using JSP?
How i upload file and save that record in database using JSP?  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail form
How to save excel sheet into mysql database using blob or clob
How to save excel sheet into mysql database using blob or clob  Hi All, I am new to java and i need to upload excel sheet to mysql, please suggest me the steps to do this, i am able to connect to the database, from there i don't
binding jComboBox to mysql database - Swing AWT
binding jComboBox to mysql database  I am using netbeans 6.5 How to populate jComboBox with data of specific column of mysql database table? I...){ e.printStackTrace(); } JComboBox comboTypesList = new
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc  how to make a radio button selected when retrieving data from database using struts framework and spring jdbc
How to send the data selected from drop down menu from html page to sql 2005 database.
system ,how can I save these data in database and how to retrieve later .Thanks...How to send the data selected from drop down menu from html page to sql 2005 database.  Dear Sir, If I want to save the information provided
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL  <html> <head> <title>online exam</title> </head> <body> <div
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL  <html> <head> <title>online exam</title> </head> <body> <div
JComboBox
JComboBox  I want to change the index of one jComboBox according to the selected index of another jComboBox. I can do it.Also the user should have the ability to select or change the index of the second combobox according
jComboBox
jComboBox  I want to change the index of one jComboBox according to the selected index of another jComboBox. I can do it.Also the user should have the ability to select or change the index of the second combobox according

Ads