Ayant bloqué sur un autre projet java (ou j'ai aussi posté une question), je me retrouve de nouveau bloqué.
Voici mon code :
Login.java :
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
setVisible(false);
nom = jTextField1.getText() ;
passwd = jPasswordField1.getPassword() ;
Main.connex();
}
( ... )
public String returnNom(){
return nom ;
}
public String returnPasswd(){
password = new String(passwd) ;
return password ;
}
( ... )
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JTextField jTextField1;
Main.java :
jTextField1 = new javax.swing.JTextField();
jPasswordField1 = new javax.swing.JPasswordField();
( ... )
public void connex () {
new connexion().setVisible(true) ;
login = Login.returnNom() ;
passwd = Login.returnPasswd() ;
try {
Class.forName("com.mysql.jdbc.Driver") ;
Connection connexion = DriverManager.getConnection("jdbc:mysql://localhost/kop", login , passwd);
Statement instruction = connexion.createStatement();
}
catch (SQLException ex){
JOptionPane.showMessageDialog(null, "JDBC Fehler:\n"+ex.getMessage());
}
catch (ClassNotFoundException ex){
}
}
et j'ai comme erreur (la ou c'est bleu) :
Login.java:116: non-static method connex() cannot be referenced from a static context
Main.java:24: non-static method returnNom() cannot be referenced from a static context
Main.java:25: non-static method returnPasswd() cannot be referenced from a static context
Merci d'avance pour votre aide