Hesh
2013-01-25 02:54:30 UTC
this is what i typed
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class Supplier extends javax.swing.JFrame {
private static Connection con;
public static Connection getMyConnection() throws Exception{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Inventory","root","1234");
return con;
}
public Supplier() {
initComponents();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try{
Class.forName("com.mysql.jdbc.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/Inventory","root","1234");
Statement s = con.createStatement();
s.executeUpdate("insert into Supplier Values('" +no.getText()+ "','" +Sname.getText()+ "','" +Saddress.getText()+ "')");
}
catch(Exception ex){
ex.printStackTrace();
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
try{
Class.forName("com.mysql.jdbc.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/Inventory","root","1234");
Statement s = con.createStatement();
s.executeUpdate("DELETE FROM Supplier WHERE Sno='"+no.getText()+"',Name='"+Sname.getText()+"',Address='"+Saddress.getText()+"'");
}catch(Exception ex){
ex.printStackTrace();
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Supplier().setVisible(true);
}
});
}