
how to create student details using applets

import java.awt.*;
import java.sql.*;
import java.applet.*;
import java.awt.event.*;
class RegistrationApplet extends Applet implements ActionListener{
TextField text1,text2,text3,text4;
Label label1,label2,label3,label4;
Button button;
public void init() {
text1=new TextField(15);
text2=new TextField(15);
text3=new TextField(15);
text4=new TextField(15);
label1=new Label("First Name");
label2=new Label("Last Name");
label3=new Label("Address");
label4=new Label("Phone No");
button=new Button("Save");
label1.setBounds(10,10,100,20);
text1.setBounds(120,10,100,20);
label2.setBounds(10,40,100,20);
text2.setBounds(120,40,100,20);
label3.setBounds(10,70,100,20);
text3.setBounds(120,70,100,20);
label4.setBounds(10,100,100,20);
text4.setBounds(120,100,100,20);
button.setBounds(120,130,100,20);
add(label1);
add(text1);
add(label2);
add(text2);
add(label3);
add(text3);
add(label4);
add(text4);
button.addActionListener(this);
}
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
String value3=text3.getText();
String value4=text4.getText();
System.out.println(value1);
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "root";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
Statement st = con.createStatement();
int k=st.executeUpdate("insert into data(firstname,lastnameaddress,contactno) values('"+value1+"','"+value2+"','"+value3+"','"+value4+"')");
JOptionPane.showMessageDialog(null,"Data is successfully saved");
}
catch(Exception e){}
}
}
For more information, visit the following links:
http://www.roseindia.net/tutorial/java/swing/studentApplication.html
http://www.roseindia.net/java/example/java/swing/addeditanddeleteemployee_inf.shtml
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.