import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import javax.swing.*;
public class ContractYear extends JFrame {
JFrame f=new JFrame();
JLabel label1=new JLabel("Name: ");
JLabel label2=new JLabel("Address: ");
JLabel label3=new JLabel("");
JButton SubmitButton=new JButton("Submit");
JTextField text1=new JTextField(20);
JTextField text2=new JTextField(20);
JPanel p=new JPanel(new GridLayout(2,2));
{
p.add(label1);
p.add(text1);
p.add(label3);
p.add(label2);
p.add(text2);
p.add(SubmitButton);
f.add(p);
f.setVisible(true);
f.pack();
}
public static void main(String[] args) throws SQLException {
}
private void SubmitButtonActionPerformed(java.awt.event.ActionEvent evt) {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/MyStudentProfile", "root", "hejsan123");
try{
Statement st=con.createStatement();
String s1=text1.getText();
String s2=text2.getText();
st.executeUpdate("insert into employee (Forename , Sirname ) values (" + s1+ ","+s2+ ")");
}catch(Exception e){
System.out.println(e.toString());
}
}
}
Now getting an error with:
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/MyStudentProfile", "root", "hejsan123");
Unhandled exception type ClassNotFoundException
Any ideas?