Ajout Modif
Ajout Modif
/*
*/
/**
* @author pc
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
Container con=null;
public ajout()
con=getContentPane();
con.setLayout(new FlowLayout());
setSize(new Dimension(1200,1000));
con.add(l1);
con.add(t1);
con.add(l2);
con.add(t2);
con.add(l3);
con.add(t3);
con.add(b1);
con.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
if (toto.getSource()==b2)
else
try
//chargement pilote
Class.forName("oracle.jdbc.driver.OracleDriver");
//URl le chemin
Connection co=null;
co=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","marah");
Statement s1 = co.createStatement();
Statement s2 = co.createStatement();
//declaration de la requete
//execution de la requete
ResultSet r = s2.executeQuery(req2);
int existe=0;
while(r.next())
existe=1;
if (existe==1)
{
JOptionPane.showMessageDialog(null,"Matricule existe deja ???");
else
int res=s1.executeUpdate(req);
JOptionPane.showMessageDialog(null,"insertion okkkkkkkkkkkkkk");
t1.setText("");
t2.setText("");
t3.setText("");
catch(ClassNotFoundException e1)
JOptionPane.showMessageDialog(null,"err de pilote");
catch(SQLException e2)
new ajout().setVisible(true);
}
Modification
/*
*/
/**
* @author pc
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
Container con=null;
public modif()
try
//chargement pilote
Class.forName("oracle.jdbc.driver.OracleDriver");
//URl le chemin
Connection co=null;
co=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","marah");
Statement s2 = co.createStatement();
//declaration de la requete
//execution de la requete
ResultSet r = s2.executeQuery(req2);
while(r.next())
com.addItem(r.getInt("mat"));
}
catch(ClassNotFoundException e1)
JOptionPane.showMessageDialog(null,"err de pilote");
catch(SQLException e2)
con=getContentPane();
con.setLayout(new FlowLayout());
setSize(new Dimension(1200,1000));
con.add(l1);
con.add(com);
con.add(l2);
con.add(t2);
con.add(l3);
con.add(t3);
con.add(b1);
con.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
com.addActionListener(this);
if (toto.getSource()==b2)
System.exit(0);
else if (toto.getSource()==b1)
try
//chargement pilote
Class.forName("oracle.jdbc.driver.OracleDriver");
//URl le chemin
Connection co=null;
co=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","marah");
Statement s1 = co.createStatement();
//declaration de la requete
//execution de la requete
int res=s1.executeUpdate(req);
JOptionPane.showMessageDialog(null,"Modification is okkkkkkkkkkkkkkkkk");
catch(ClassNotFoundException e1)
JOptionPane.showMessageDialog(null,"err de pilote");
catch(SQLException e2)
else
try
//chargement pilote
Class.forName("oracle.jdbc.driver.OracleDriver");
//URl le chemin
Connection co=null;
co=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","marah");
//creation espace memoire pour exection de la requete
Statement s2 = co.createStatement();
//declaration de la requete
//execution de la requete
ResultSet r = s2.executeQuery(req2);
while(r.next())
t2.setText(r.getString("no"));
t3.setText(r.getString("mg"));
catch(ClassNotFoundException e1)
JOptionPane.showMessageDialog(null,"err de pilote");
catch(SQLException e2)
new modif().setVisible(true);