Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java Programming Question

Have Programming Question? Ask it here!
 
 
 


Soummya Kanti Ghosh
Java Programming Question
1 Answer(s)      3 years and 6 months ago
Posted in : Java Beginners


Write a program in Java to create student information form an submit detail in database.


Advertisement
View Answers

January 28, 2011 at 10:49 AM


Hi Friend,

Try this:

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class  FormData{

    public static void main(String[] args){
    JFrame f=new JFrame();
    JLabel label1=new JLabel("Name: ");
    JLabel label2=new JLabel("Date Of Birth: ");
    JLabel label3=new JLabel("Address: ");
    JLabel label4=new JLabel("Contact No: ");
    final JTextField text1=new JTextField(20);
    final JTextField text2=new JTextField(20);
    final JTextField text3=new JTextField(20);
    final JTextField text4=new JTextField(20);
    JButton b=new JButton("Save");
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        String v1=text1.getText();
        String v2=text2.getText();
        String v3=text3.getText();
        int v4=Integer.parseInt(text4.getText());

        try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           int i=st.executeUpdate("insert into data(name,dateOfBirth,address,contactNo) values('"+v1+"','"+v2+"','"+v3+"',"+v4+")");
           JOptionPane.showMessageDialog(null,"Data is inserted successfully");
        }
        catch(Exception ex){
            System.out.println(ex);
        }
        }
    });
        JPanel p=new JPanel(new GridLayout(5,2));
        p.add(label1);
        p.add(text1);
        p.add(label2);
        p.add(text2);
        p.add(label3);
        p.add(text3);
        p.add(label4);
        p.add(text4);
        p.add(b);
        f.add(p);
        f.setVisible(true);
        f.pack();
    }
}

Thanks



Related Tutorials/Questions & Answers:
Java Programming Question
Java Programming Question  write a program in java to show thread working with sleep and wait method   Hi Friend, Please visit the following links: Wait Method Sleep Method Thanks
programming question - Java Magazine
programming question  I have an SGVT map displaying on a phone emulator but then want to search for a given location on the map and display... tool. I need a java solution to this please
Advertisements
Java Programming Question
Java Programming Question  Write a program in Java to accept 10 different numbers an store it in text file.   Hi Friend, Try this: import java.io.*; import java.util.*; class AcceptNumbers{ public static void main
Java Programming Question
Java Programming Question  Write a program in Java to create a menu bar with the help of event handlers.   Hi Friend, Try this: import javax.swing.*; import java.awt.event.*; public class SwingMenuBar{ public
Java Programming Question
Java Programming Question  Write a program in Java to create student information form an submit detail in database.   Hi Friend, Try this: import java.awt.*; import java.sql.*; import javax.swing.*; import
core java programming question
core java programming question  How to write a java program to list the customer names arrived to a restuarant on a particular date in alphabetical order with arguments as 1 filename yymmdd cust   Hi Friend, Try
programming question - Java Beginners
programming question  Create a class named Movie that can be used with your video rental business. The Movie class should track the Motion Picture Association of America (MPAA) rating (eg., Rated G, PG-13, R), ID Number
Java programming question - Java Beginners
Java programming question   Give the definition of a class named Doctor whose objects are records for a clinic's doctors. This class will be derived class of the class SalariedEmployee that is given below the question. A Doctor
Java programming question - Java Beginners
Java programming question  I want to write a program that converts temperatures from celsius to fahrenheit and vice versa. It also converts kilometers to miles and vice versa using "methods".  Hi Friend, Try
socket programming question
socket programming question   can you respond to me the multiple clients chat application java code and a server that manages the clients using the socket programming in java
socket programming question
socket programming question   can you respond to me the multiple clients chat application java code and a server that manages the clients using the socket programming in java
socket programming question
socket programming question   can you respond to me the multiple clients chat application java code and a server that manages the clients using the socket programming in java
Java Programming
Java Programming  Hi, What is Java Programming? How I can learn Java Programming in one month? Thanks
Question in Java ??
Question in Java ??   Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number squrfoot
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
Question on java
Question on java  why java is not purely oop?   java is not purely OOP because 1.) Multiple Inheritance is not supported. 2.) It uses primitive data type. 3.) static method can be called without creating instances
Question Java>?
Question Java>?  **ï??· Create a new class called Bank and in the main method use class Account (lab 4) to create an array of 10 accounts. ï??· Enter data for all accounts (account number,name, balance). ï??· Add
java question
java question   Create a class called Complex to perform arithmetic operations with complex numbers. 1- Use double variables to represent the fields of the class. 2- Provide a no-argument constructor with default values in case
java question :)
java question :)  write java program to use vector in ArrayList with add, remove,sort   import java.util.Vector; public class... Element MUAYAD"); vc.add("Vector Element JAVA"); vc.add("Vector Element
JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java
JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java
JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java
java question
java question  find the 127 twin pair in java
java question
java question  the purpose of defining multiple constructor in java
java question
java question  How to find the longest and shortest line from the file in case of java and java program should read the filename from the keyboard
java question
java question  wats dynamic dispatching
java question
java question  how to write a java program that, given a friend name , display the phone number and the email address for that friend
java question
java question  Please, give me sample program for insert Audio(sound) on Frame in swing in java
programming java qus.
programming java qus.  write a import statement that import all the inner class of outer class .outer class must not be imported??   You must not ask similar question more then once. If it happens the user id
Java Programming
Java Programming  Write a Java program that prompt user to input a number of students in a class. Then, prompt user to input the student?¢â??¬â??¢s programming mark. Determine how many student get A+ and A for their grade
java question
java question  anyone provide the code to call c++ function from java   Here you will find details how to implement the c++ into the java. http://www.javaworld.com/javatips/jw-javatip23.html
Java programming - Java Beginners
Java programming  hi sir, my question are as follows... hope u can solve my java programming problem.. Write a program to develop a class to hold... to : http://www.roseindia.net/java/beginners/index.shtml Thanks
Java programming
Java programming  What is the Role of OOP in java
Java programming
Java programming  What is the Role of OOP in java
Java Question
Java Question  can u give me one expample in which conditions we... in java includes only abstract methods i.e. methods have signatures only (or we... in java defines that it must be implemented by any class to make use of it. One
java question
java question  what are the exactly J2EE concepts.. struts and hybernates coming under which catagiry
java question
java question  input any number and check if sum of alternate digit is palindrome
java question
java question  how to create date and time based pgm in java... in db table if date and time crossed automatically update in the db and inform to login user as pop ups   http://www.roseindia.net/jsp/loginstatus.shtml
java question
java question  i wrote to java code to get data populated in the Revision field of table InventDim 2.Failing to successfully do the above, i tried to use the ConfigId field of table InventDim for the same purpose, by labeling
java question
java question  sir, can you give me the code for online banking using netbeans and mysql in j2ee with its database connectivity
java question
java question  sir, can you give me the code for online banking using netbeans and mysql in j2ee with its database connectivity
java question
java question  when we use the Abstract class and interface?   Please visit the following link: Abstract class and Interface
java question
java question  Can any one send me the source code to get confirmation after the successful registration to our mobile
java question
java question  I am converting a .net website into java one. Can you help me how to code things step by step. project name - src -java -main -webapp - common - jsp - css - images - javascripts I
Java question
Java question  Write a program that converts a (C to F Converter from 0 - 20) and writes the output to a file instead of the screen. Open the file in Notepad to confirm the output
java question
java question  i have a string like "My name is arvind.i live in bangalore.i study in college.".the problem is that i hav to break this string into three seperate lines
java Question
java Question  write a program that reads an integer and check whether it is even. for example, if your input is 25, the should be: is 25 an even number? false if your input is 2000, the should be: is 2000 an even number?true
java Question
java Question  write a program that reads an integer and check whether it is even. for example, if your input is 25, the should be: is 25 an even number? false if your input is 2000, the should be: is 2000 an even number?true
java question
java question  comparator and comparable   Differences: a)A comparable object is capable of comparing itself with another object while...: http://www.roseindia.net/help/java/c/comparable-interface.shtml http
 

 

 

DMCA.com