Urgent accéder au base de données avec interface graphique

Fermé
Excelence bougherra - 18 févr. 2016 à 10:16
Pierre1310 Messages postés 8554 Date d'inscription lundi 21 décembre 2015 Statut Membre Dernière intervention 21 juillet 2020 - 18 févr. 2016 à 10:19
Bonjour, Je commence en java alors soyez gentils plzzzzz :-)
Je veux connecter ma base de donner créer sous phpMyAdmin avec mon interface graphique en java développée sous eclipse ,
mais je sais pas comment va accédée a ma base avec mon interface graphique
Quelqu'un a-t-il une idée ?
Merci beaucoup.
voici mon code :
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JButton;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.AbstractAction;
import javax.swing.Action;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JLabel;
import java.awt.FlowLayout;
import javax.swing.Box;

public class frame1 {

private JFrame frame;
private JTextField textField;
private JPasswordField passwordField;
private final Action action = new SwingAction();

/**
  • Launch the application.
  • /

public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame1 window = new frame1();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
  • Create the application.
  • /

public frame1() {
initialize();
}
/**
  • Initialize the contents of the frame.
  • /

private void initialize() {
frame = new JFrame("connection");
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JButton btnNewButton = new JButton("OK");

btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg) {




}
});
btnNewButton.setAction(action);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg) {



}
});
frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
frame.getContentPane().add(btnNewButton);

textField = new JTextField();

frame.getContentPane().add(textField);
textField.setColumns(10);

passwordField = new JPasswordField();
frame.getContentPane().add(passwordField);
passwordField.setColumns(10);
}

private class SwingAction extends AbstractAction {
public SwingAction() {
putValue(NAME, "SwingAction");
putValue(SHORT_DESCRIPTION, "Some short description");
}
public void actionPerformed(ActionEvent e) {
}
}
}



1 réponse

Pierre1310 Messages postés 8554 Date d'inscription lundi 21 décembre 2015 Statut Membre Dernière intervention 21 juillet 2020 645
Modifié par Pierre1310 le 18/02/2016 à 10:22
Bonjour,

package gmaoMoulage.entities;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


/**
  • * * Entity implementation class for Entity : Communication * */ @NamedQueries({ @NamedQuery(name="sqlCommunicationTrue", query="SELECT c FROM Communication c WHERE ((c.etatCommunication='True') OR (c.etatCommunication='False')) ORDER BY c.idCommunication"),////////////////////////////// @NamedQuery(name="sqlCommunicationParIdCommunication", query="SELECT c FROM Communication c WHERE c.idCommunication=:idCommunication"),////////////////////////////// @NamedQuery(name="sqlCommunicationParNomCommunication", query="SELECT c FROM Communication c WHERE c.nomCommunication=:nomCommunication"), //////////////////////////////@NamedQuery(name="sqlCommunicationParEtatCommunication", query="SELECT c FROM Communication c WHERE c.etatCommunication=:etatCommunication"), //////////////////////////////@NamedQuery(name="sqlCommunicationChangementEtatTrue", query="UPDATE Communication SET etatCommunication = 'True' WHERE NomCommunication:=nomCommunication"), //////////////////////////////@NamedQuery(name="sqlCommunicationChangementEtatFalse", query="UPDATE Communication SET etatCommunication = 'False' WHERE NomCommunication:=nomCommunication") }) //////////////////////////////@Entity@Table(name = "Communication")//////////////////////////////public class Communication implements Serializable { //////////////////////////////private static final long serialVersionUID = 1L; ////////////////////////////// @Id @GeneratedValue( strategy = GenerationType.IDENTITY) @Column(name= "IdCommunication") private Long idCommunication; ////////////////////////////// @Column(name= "NomCommunication") private String nomCommunication; //////////////////////////////@Column(name= "EtatCommunication") private String etatCommunication; //////////////////////////////public Long getIdCommunication() { return idCommunication; } //////////////////////////////public void setIdCommunication(Long idCommunication) { this.idCommunication = idCommunication; } ////////////////////////////// public String getNomCommunication() { return nomCommunication; } //////////////////////////////public void setNomCommunication(String nomCommunication) { this.nomCommunication = nomCommunication; } //////////////////////////////public String getEtatCommunication() { return etatCommunication; } //////////////////////////////public void setEtatCommunication(String etatCommunication) { this.etatCommunication = etatCommunication; } }


personnellement je travaille aussi sur eclipse mais avec sql serveur.

Problème de pc? => Nous donner des détails on est pas devin ...
Google est votre ami n'oubliez pas !
0