java code using swings

Ads
 

java code using swings

code that should be able to enter data of student details using all swings into the access database using jdbc connectivity

View Answers

July 23, 2011 at 10:37 AM

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class  FormData{
    public static void main(String[] args){
    Frame f=new Frame();
    Label label1=new Label("Emp No: ");
    Label label2=new Label("Emp Name: ");
    Label label3=new Label("Salary: ");
    final TextField text1=new TextField(20);
    final TextField text2=new TextField(20);
    final TextField text3=new TextField(20);
    Button b=new Button("Save");
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        int v1=Integer.parseInt(text1.getText());
        String v2=text2.getText();
        int v3=Integer.parseInt(text3.getText());
        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con = DriverManager.getConnection("jdbc:odbc:student");
           String sql = "insert into emp(EMP_NO,EMP_NAME,SALARY) values(?,?,?) ";
           PreparedStatement pst = con.prepareStatement(sql);

            pst.setInt(1, v1);
            pst.setString(2, v2);
            pst.setInt(3,v3);
            pst.executeUpdate();
           JOptionPane.showMessageDialog(null,"Data is inserted successfully");
        }
        catch(Exception ex){
            System.out.println(ex);
        }
        }
    });
        Panel p=new Panel(new GridLayout(5,2));
        p.add(label1);
        p.add(text1);
        p.add(label2);
        p.add(text2);
        p.add(label3);
        p.add(text3);
        p.add(b);
        f.add(p);
        f.setVisible(true);
        f.pack();
    }
}

Ads









Related Tutorials/Questions & Answers:
java code using swings
java code using swings  code that should be able to enter data of student details using all swings into the access database using jdbc connectivity
want a program for date picker by using java swings
want a program for date picker by using java swings  to write a program for the date picker by using java swings.any one please help me by providing the code to this java date picker by using the java swings.previously a program
Advertisements
Image Movement using Swings
Image Movement using Swings  How to move image using Swings
An application using swings and vector methods
An application using swings and vector methods   Hi, I want an application in Java swings which uses good selection of Vectors methods
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
java code using while loop
java code using while loop  
java code for PartialSearch using Map????
java code for PartialSearch using Map????  java code for Partial Search using Map
Java Swings
Java Swings  I am doing one project on java Swings, in this i have created one jframe where i defined some JButtons and Jcombobox's, here i need to insert one JTable with headers(IN CURRENT JFrame only).pls help me urgently
java swings
java swings  Hi, I have one class file using three panel methods,the three methods is used for three tabs.then how can i set the background image.Please send the sample code for me. I already posted two questions,but i didnt get
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
java swings
java swings  Hi, I need the sample code for how to set the background image using jframe and also set the jtext field and jlable boxes under the bachground image. Please send the code immediately,its very urgent.Please send me
code for multiplication of matrix in java using methods
code for multiplication of matrix in java using methods  code for multiplication of matrix in java using methods
java swings
java swings  Hi, I need a sample code for once click the exit tab the frame window will be closed. Instead of button close i need tab close option.Please send the sample code immediately.......?Its very urgent........ Thanks
parsing xml file using java code
parsing xml file using java code  parsing a xml file using java code
java swings
java swings  hi... I am having multiple swing forms.. when i click on a button another form is going to opening but it is opening as different form... Now i want it to be open dynamically instead separately.... Is there any
java swings
java swings  how can we use the shared locks of dbms in java? I am working on a mini project which is based on the eamcet councilling .i am struck with a problem where if a student select a college and a branch and sees
Reading RDF file using Java code in Eclipse
Reading RDF file using Java code in Eclipse  Could you please tel me what this statement means - Model model = ModelFactory.createDefaultModel
java code using combobox,radiobutton,checkbox
java code using combobox,radiobutton,checkbox  hi, send me java code for entering student details into ms access database, the code should includes combo box,radiobutton and checkboxes pl send as early as possible
View source code of a html page using java ..
View source code of a html page using java ..  I could find the html source code of a web page using the following program, http://download.oracle.com/javase/1.4.2/docs/api/java/net/URLConnection.html i could get the html code
Java Swings - Java Beginners
Java Swings  hi , I am doing project using netbeans. I have... code: http://www.roseindia.net/java/example/java/swing... they are value from existing component&custom code, but i dont know how to use
swings - Java Beginners
for this in google, but i got very difficult programs. i am beginner in java swings . i want... Friend, Try the following code: import java.awt.*; import javax.swing....); } } For more information, visit the following link: http://www.roseindia.net/java
java plugin code for nutch using filter indexer
java plugin code for nutch using filter indexer  hello: i want... in the doc.add(name,value) . I don't know what is the error in it. Tthis is the code... = conf; } } I think that the error is in using parsedData but I don't know what I
java swings - JavaMail
java swings  Hi sir,i am doing a project on swings,i don't have any...://www.roseindia.net/java/example/java/swing/GrideComponents.shtml http://www.roseindia.net/java/example/java/swing/AbsCoordinate.shtml http://www.roseindia.net
determinant of n*n matrix using java code
determinant of n*n matrix using java code  Here is my code: import java.util.Scanner.*; import java.util.*; public class determinantcode { double A[][]; double m[][]; int N; public input() { Scanner s=new
java swings - Java Beginners
java swings  Hi, I need the code for how can i set the joptionpane color(background and foreground). can i set the delay time for joptionpane display. Please send the code .its urgent. Thanks, Valarmathi
java swings - Java Beginners
java swings  hi, I send two questions ,but i didnt reply .please...... c:/valar/ only. This code is only for c:/valar/some.txt,pdf... import...(); text.setText(filename); this.repaint(); } } } Please send the code
java source code to send group mails using struts2
java source code to send group mails using struts2  code to send group mails using struts2
swings - Java Beginners
swings  hi While i am going to execute my code the following... Exception in thread "main" Exception in thread "main" Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) there is no error in my code. i am sure about
java source code to create mail server using struts2
java source code to create mail server using struts2  java source code to create mail server using struts2
making of dynamic textfields using swings
making of dynamic textfields using swings  how to crate dynamic texfields by clicking on button
download xml file from website using java code
download xml file from website using java code  how to download xml file from website using java code

Ads