Wissal
unread,May 25, 2009, 7:47:32 PM5/25/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Supervision des réseaux workteam
Bonjour,
j'apprécierai vraiment votre aide pcq ca fait plus de deux jour que je
suis bloquée dans ce probleme
jai besoin d'une connexion base de données
alors jai choisi mysql connector/j je l'ai mis dans le repertoire jar
de mon eclipse et je lai ajouté depui les proprietés de mon projet
j'ai aussi ajouté le chemin dans le PATH
j'ai installé easyphp et crée ma base de donné (DMN) et une table user
mais dés que je lance ma fenetre j'ai une erreur : "driver non trouvé"
je ne sais pas ou est ce que je dois mettre le connector ou bien que
mettre dans le classpath c peut etre ca mon prob..ou je ne c pas
voici mon code au cas ou jai un prob dans le code que jai pas vu:
package src;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import com.cloudgarden.layout.*;
public class LoginJFrame extends javax.swing.JFrame {
private JButton OK;
private JLabel jLabelTitre;
private JLabel jLabelMDP;
private JLabel jLabelNom;
private JTextField mdp;
private JTextField name;
Connection connection = null;
ResultSet rs = null;
{
//Set Look & Feel
try {
javax.swing.UIManager.setLookAndFeel
(javax.swing.UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
LoginJFrame inst = new LoginJFrame();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
});
}
public LoginJFrame() {
super();
///connnexion a la bdd
try
{
// Chargement des drivers SQL
Class.forName ("com.mysql.Driver").newInstance();
}
catch (ClassNotFoundException a)
{
System.out.println ("Driver non trouve");
}
catch (Exception b)
{
System.out.println ("Problème sur chargement de driver JDBC");
}
try
{
// Etablissement de la connexion avec la base
connection = DriverManager.getConnection ("jdbc:mysql://localhost/
DMN", "root", "");
}
catch (SQLException c)
{
System.out.println ("Connexion refusée ou base inconnue");
}
catch (Exception d)
{
System.out.println ("Problème sur connexion");
}
initGUI();
}
private void initGUI() {
try {
AnchorLayout thisLayout = new AnchorLayout();
getContentPane().setLayout(thisLayout);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setName("frameLogin");
this.setTitle("Login");
{
jLabelTitre = new JLabel();
getContentPane().add(jLabelTitre, new AnchorConstraint(65, 567, 196,
121, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL,
AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
jLabelTitre.setText("Identifiez vous");
jLabelTitre.setPreferredSize(new java.awt.Dimension(116, 23));
jLabelTitre.setFont(new java.awt.Font("Agency FB",1,18));
}
{
jLabelMDP = new JLabel();
getContentPane().add(jLabelMDP, new AnchorConstraint(530, 336, 627,
78, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL,
AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
jLabelMDP.setText("Mot de passe");
jLabelMDP.setPreferredSize(new java.awt.Dimension(67, 16));
}
{
jLabelNom = new JLabel();
getContentPane().add(jLabelNom, new AnchorConstraint(384, 294, 469,
78, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL,
AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
jLabelNom.setText("Nom");
jLabelNom.setPreferredSize(new java.awt.Dimension(56, 14));
}
{
mdp = new JPasswordField();
getContentPane().add(mdp, new AnchorConstraint(536, 763, 657, 355,
AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL,
AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
mdp.setPreferredSize(new java.awt.Dimension(106, 20));
}
{
name = new JTextField();
getContentPane().add(name, new AnchorConstraint(366, 763, 481, 355,
AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL,
AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
name.setPreferredSize(new java.awt.Dimension(106, 19));
}
{
OK = new JButton();
getContentPane().add(OK, new AnchorConstraint(742, 963, 900, 678,
AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL,
AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
OK.setText("OK");
OK.setPreferredSize(new java.awt.Dimension(74, 26));
OK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// TODO verifier le mdp
NewSwingApp N=new NewSwingApp();
N.setVisible(true);
dispose();
}
});
}
//pack();
/// Exécution des requêtes
try
{
Statement stmt = connection.createStatement();
String requete = null;
requete = "SELECT nom_user, mdp From user";
rs = stmt.executeQuery(requete);
while (rs.next())
{
// Affichage les resultats de la requete SQL
name.setText(rs.getString(1));
}
}
catch (Exception d)
{
System.out.println ("Problème la requete");
}
this.setSize(268, 195);
} catch (Exception e) {
e.printStackTrace();
}
}
}
merci d'avance