Probleme JAVA WEBSTART

Fermé
rainbow89 Messages postés 121 Date d'inscription lundi 8 mars 2010 Statut Membre Dernière intervention 16 novembre 2015 - 2 oct. 2011 à 14:09
rainbow89 Messages postés 121 Date d'inscription lundi 8 mars 2010 Statut Membre Dernière intervention 16 novembre 2015 - 3 oct. 2011 à 16:38
Bonjour,


je viens de deployer mon application JAVA/JDBC mais je me suis rendu compte qu'en appuyant sur le bouton qui lance un formulaire d'ajout RIEN NE SE PASSE pourtant sur eclipse ca marche :((!!! mais su la version deployee nn
svp quelle serait la raison de ce probleme ??

voici le code de mon formulaire d'ajout:
public class FormRep extends JFrame {

private JButton b1;
private JPanel P1;



private JLabel nao=new JLabel("N° AO/BC (*)",JLabel.LEFT);
private JTextField t1=new JTextField(20);


private JLabel ncl= new JLabel("N° Client (*)",JLabel.LEFT);
private JTextField t2=new JTextField(20);

private JLabel date= new JLabel("Date",JLabel.CENTER);
private JTextField t3=new JTextField(20);
private JButton b = new JButton(" ");

private JLabel resp= new JLabel("Responsable",JLabel.LEFT);
private JComboBox t4=new JComboBox();

private JLabel obj= new JLabel("Objet (*)",JLabel.LEFT);
private JTextField t5=new JTextField(20);


private JLabel mt= new JLabel("Montant",JLabel.LEFT);
private JTextField t6=new JTextField(20);

private JLabel duree= new JLabel("Durée",JLabel.LEFT);
private JTextField t7=new JTextField(17);
private JLabel mois= new JLabel("Mois",JLabel.RIGHT);

private JLabel comm= new JLabel("Commentaire",JLabel.LEFT);
private JTextField t8=new JTextField();


private JLabel offre= new JLabel("Offre Technique",JLabel.LEFT);
private JTextField t9=new JTextField(20);

private JLabel border= new JLabel("Bordereau De Prix",JLabel.LEFT);
private JTextField t10=new JTextField(20);

private boolean pass=true;


JPanel p=new JPanel();
JPanel pt=new JPanel();
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JPanel p3=new JPanel();
JPanel p4=new JPanel();
JPanel p5=new JPanel();
JPanel p6=new JPanel();
JPanel p7=new JPanel();
JPanel p8=new JPanel();
JPanel p9=new JPanel();
JPanel p10=new JPanel();
JPanel p11=new JPanel();

public FormRep() throws ClassNotFoundException, SQLException{
// TODO Auto-generated constructor stub

// bl=new FlowLayout(FlowLayout.CENTER);


t1.setText("0");
t2.setText("0");
t3.setText("0");
t5.setText("-");
t6.setText("0");
t7.setText("0");
t8.setText("-");
t9.setText("-");
t10.setText("-");
p3.setAlignmentX(CENTER_ALIGNMENT);
b1= new JButton("Valider");
P1= new JPanel();

Icon loginIcon = new ImageIcon("image.jpg");
b.setIcon(loginIcon);

this.setLayout(null);

setSize(550,520);
setTitle("Ajouter Une Réponse Commerciale");
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setResizable(true);

JLabel l=new JLabel(" Ajout D'appels D'offre/Bons de Commandes ");
Color C = new Color(245,255,250);
Font font = new Font("Monotype Corsiva",Font.BOLD|Font.ITALIC,20);
l.setFont(font);
l.setForeground(Color.BLUE);

pt.add(l);


p.add(pt);
((JPanel)getContentPane()).add(p);

P1.setBackground(C);

date.setPreferredSize(getPreferredSize());


t1.setHorizontalAlignment(JTextField.CENTER);
t2.setHorizontalAlignment(JTextField.CENTER);
t3.setHorizontalAlignment(JTextField.CENTER);
t5.setHorizontalAlignment(JTextField.CENTER);
t6.setHorizontalAlignment(JTextField.CENTER);
t7.setHorizontalAlignment(JTextField.CENTER);
t8.setHorizontalAlignment(JTextField.CENTER);
//Agrandir le champ de Commentaire
t8.setPreferredSize(new Dimension(220,40));

t9.setHorizontalAlignment(JTextField.CENTER);
t10.setHorizontalAlignment(JTextField.CENTER);
//Afficher un DatePicker

final JFrame f = new JFrame();
f.getContentPane().add(P1);
f.pack();
//f.setVisible(true);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
t3.setText(new DatePicker(f).setPickedDate());
}
});

//Remplir le comboBox de Responsables A Partir de la Base De Donnees
Class.forName("com.mysql.jdbc.Driver");
Connection c=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/uniforce","root","root");

String req= "select DISTINCT responsable from reponses";
Statement stmt;

try {
stmt = c.createStatement();
ResultSet res = stmt.executeQuery(req);
while(res.next())
{
t4.addItem(res.getString(1));

}
res.close();
} catch (SQLException i) {
String error= i.getNextException().toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

}

setLayout(new GridBagLayout());
//GridBagConstraints gbc = new GridBagConstraints();

nao.setForeground(Color.BLUE);
ncl.setForeground(Color.BLUE);
date.setForeground(Color.BLUE);
resp.setForeground(Color.BLUE);
obj.setForeground(Color.BLUE);
mt.setForeground(Color.BLUE);
duree.setForeground(Color.BLUE);
comm.setForeground(Color.BLUE);
offre.setForeground(Color.BLUE);
border.setForeground(Color.BLUE);

JLabel v=new JLabel(" ");
JButton bOffre = new JButton("Parcourir");
JButton bBorder = new JButton("Parcourir");


Date current = new Date(new GregorianCalendar().getTime().getTime());
t3.setText(current.toString());



p1.add(v);
p1.add(nao);
p1.add(t1);

p2.add(ncl);
p2.add(t2);

p3.add(date);
p3.add(t3);
p11.add(b);

p4.add(resp);
p4.add(t4);

p5.add(obj);
p5.add(t5);

p6.add(mt);
p6.add(t6);

p7.add(duree);
p7.add(t7);
p7.add(mois);

p8.add(comm);
p8.add(t8);

p9.add(offre);
p9.add(t9);
p9.add(bOffre);

p10.add(border);
p10.add(t10);
p10.add(bBorder);

P1.add(p);
P1.add(p1);
P1.add(p2);
P1.add(p3);
P1.add(p11);
P1.add(p4);
P1.add(p5);
P1.add(p6);
P1.add(p7);
P1.add(p8);
P1.add(p9);
P1.add(p10);
synchronZones();

setContentPane(P1);




P1.add(b1);




bOffre.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFileChooser chooser1 = new JFileChooser();
int returnVal = chooser1.showOpenDialog(getParent());
if(returnVal == JFileChooser.APPROVE_OPTION) {

String POffre=chooser1.getSelectedFile().getAbsolutePath();

t9.setText(POffre);

}

}
} );

bBorder.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFileChooser chooser2 = new JFileChooser();
int returnVal = chooser2.showOpenDialog(getParent());
if(returnVal == JFileChooser.APPROVE_OPTION) {

String POffre=chooser2.getSelectedFile().getAbsolutePath();

t10.setText(POffre);

}

}
} );


b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
// TODO Auto-generated method stub



// Gestion des NumberFormat Exception

if (t1.getText().equals("0") == true)
try {
pass=false;

dispose();

FormRep ff=new FormRep();
ff.setVisible(true);

throw new SaisieErroneeException("Le Champ N° AO/BC est vide");

} catch (SaisieErroneeException e2) {
// TODO Auto-generated catch block
String error= e2.toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
String error= e1.getException().toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

} catch (SQLException e1) {
// TODO Auto-generated catch block
String error= e1.toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

}

if (t2.getText().equals("0") == true)
try {
pass=false;
dispose();


FormRep f=new FormRep();
f.setVisible(true);
//videchamps();
throw new SaisieErroneeException("Le Champ N° Client est vide");
} catch (SaisieErroneeException e2) {
// TODO Auto-generated catch block
String error= e2.toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
String error= e1.getException().toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

} catch (SQLException e1) {
// TODO Auto-generated catch block
String error= e1.toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

}


if (t5.getText().equals("-") == true)
try {
pass=false;
dispose();

FormRep ff=new FormRep();
ff.setVisible(true);

throw new SaisieErroneeException("Le Champ Objet est vide");

} catch (SaisieErroneeException e2) {
// TODO Auto-generated catch block
String error= e2.toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
String error= e1.getException().toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

} catch (SQLException e1) {
// TODO Auto-generated catch block
String error= e1.toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);

}



if(pass==true)
{

int no= Integer.parseInt(t1.getText());
int nc=Integer.parseInt(t2.getText());


//formater la chaine en date




SimpleDateFormat dt=new SimpleDateFormat("yyyy-MM-dd");

//Conversion en java.util.Date
java.util.Date date = null;
try {
date = dt.parse(t3.getText());
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

java.sql.Date sqlDate = new java.sql.Date(date.getTime());
String resp=t4.getSelectedItem().toString();
String ob=t5.getText();
float mont=Float.parseFloat(t6.getText());
int dur=Integer.parseInt( t7.getText());
String comment=t8.getText();
String offre=t9.getText();
String Border=t10.getText();

verifier(nc);

try{
Class.forName("com.mysql.jdbc.Driver");
Connection co=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/uniforce","root","root");

Statement s=co.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);


PreparedStatement stm=(PreparedStatement) co.prepareStatement("insert into reponses values(?,?,?,?,?,?,?,?,?,?)");

//Insertion

stm.setInt(1,no);
stm.setInt(2,nc);
stm.setDate(3,sqlDate);
stm.setString(4,resp);
stm.setString(5,ob);
stm.setFloat(6,mont);
stm.setInt(7,dur);
stm.setString(8,comment);
stm.setString(9,offre);
stm.setString(10,Border);
stm.executeUpdate();
co.close();


JOptionPane.showMessageDialog(null,"Votre AO/BC a été inséré avec succès!!");
dispose();

FormRep ff=new FormRep();
ff.setVisible(true);



}
catch(SQLException s)
{

String error=s.getMessage();
JOptionPane.showMessageDialog(null,"Erreur: "+error,"Warning",JOptionPane.WARNING_MESSAGE);

}

catch(ClassNotFoundException y)
{ String error= y.getException().toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);
}

}

}
});




}


public void synchronZones(){

int L = border.getText().length();//plus long label
Dimension s=new Dimension(L * 7,20);



nao.setPreferredSize(s);
ncl.setPreferredSize(s);
date.setPreferredSize(s);
resp.setPreferredSize(s);
obj.setPreferredSize(s);
mt.setPreferredSize(s);
duree.setPreferredSize(s);
comm.setPreferredSize(s);
offre.setPreferredSize(s);
border.setPreferredSize(s);



}

public void videchamps()
{
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
t5.setText(" ");
t6.setText(" ");
t7.setText(" ");
t8.setText(" ");
t9.setText(" ");
t10.setText(" ");
}

public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub

FormRep RR= new FormRep();
RR.setVisible(true);
RR.setResizable(true);

}

public void verifier(int nc)
{


//Verfier si ce client existe deja dans la base


ResultSet res=null;
try {
Class.forName("com.mysql.jdbc.Driver");



Connection c=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/uniforce","root","root");

Statement s=c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
PreparedStatement stm=(PreparedStatement) c.prepareStatement("select * from clients where Nclient=?" );
stm.setInt(1,nc);
res=stm.executeQuery();

int j=0;
while(res.next())
{j++;}
res.close();

//si le client n'existe pas l'ajouter A La Base de donnees
if(j==0)
{



Class.forName("com.mysql.jdbc.Driver");
Connection co=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/uniforce","root","root");
Statement st=co.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
PreparedStatement stmt=(PreparedStatement) co.prepareStatement("insert into clients values (?,?,?,?,?)");
//Insertion
stmt.setInt(1,nc);
stmt.setString(2,"");
stmt.setString(3,"");
stmt.setString(4,"");
stmt.setString(5,"");
stmt.executeUpdate();
co.close();

//JOptionPane.showMessageDialog(null,"Ce Client N'existe pas dans votre BDD! Veuillez l'enregistrer d'abord. ","Warning",JOptionPane.WARNING_MESSAGE);
//System.exit(0);
}
}
catch(SQLException s)
{

String error=s.getMessage();
JOptionPane.showMessageDialog(null,"Erreur: "+error,"Warning",JOptionPane.WARNING_MESSAGE);

}

catch(ClassNotFoundException y)
{ String error= y.getException().toString();
JOptionPane.showMessageDialog(null,"Erreur: " +error,"Warning",JOptionPane.WARNING_MESSAGE);
}






}
}
A voir également:

1 réponse

rainbow89 Messages postés 121 Date d'inscription lundi 8 mars 2010 Statut Membre Dernière intervention 16 novembre 2015 3
3 oct. 2011 à 16:38
up
0