IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JDBC Java Discussion :

Problème de connection à la BD Mysql via Java


Sujet :

JDBC Java

  1. #21
    Membre Expert Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 53
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Par défaut
    Quelle est la structure de ta table ?

  2. #22
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Par défaut
    Champ###Type ##### Interclassement ### Null
    ---------------------------------------------------
    Id #### int(20) ################ # Non
    Nom ## varchar(20) # latin1_swedish_ci # Non
    Prenom varchar(20) # latin1_swedish_ci # Non
    Age ### int(3) ################### Non


    ALTER TABLE `table` ADD `Id` INT( 200 ) NOT NULL FIRST ;
    ALTER TABLE `table` ADD PRIMARY KEY ( `Id` )
    ALTER TABLE `table` ADD `Nom` VARCHAR( 20 ) NOT NULL ;
    ALTER TABLE `table` ADD `Prenom` VARCHAR( 20 ) NOT NULL ;
    ALTER TABLE `table` ADD `Age` INT( 3 ) NOT NULL ;

  3. #23
    Membre Expert Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 53
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Par défaut
    Il manque l'Id lors de la persistence de ton objet.

  4. #24
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Par défaut
    la classe est généré par hibernate synchrinizer, l'Id est bien renseigner :

    package hibernate.base;

    import java.io.Serializable;


    /**
    * This class has been automatically generated by Hibernate Synchronizer.
    * For more information or documentation, visit The Hibernate Synchronizer page
    * at http://www.binamics.com/hibernatesync or contact Joe Hudson at joe@binamics.com.
    *
    * This is an object that contains data related to the table table.
    * Do not modify this class because it will be overwritten if the configuration file
    * related to this class is modified.
    *
    * @hibernate.class
    * table="table"
    */
    public abstract class BaseTable implements Serializable {

    public static String PROP_NOM = "Nom";
    public static String PROP_AGE = "Age";
    public static String PROP_PRENOM = "Prenom";
    public static String PROP_ID = "Id";


    private int hashCode = Integer.MIN_VALUE;

    // primary key
    private java.lang.Integer _id;

    // fields
    private java.lang.String _nom;
    private java.lang.Integer _age;
    private java.lang.String _prenom;


    // constructors
    public BaseTable () {
    initialize();
    }

    /**
    * Constructor for primary key
    */
    public BaseTable (java.lang.Integer _id) {
    this.setId(_id);
    initialize();
    }

    /**
    * Constructor for required fields
    */
    public BaseTable (
    java.lang.Integer _id,
    java.lang.String _nom,
    java.lang.Integer _age,
    java.lang.String _prenom) {

    this.setId(_id);
    this.setNom(_nom);
    this.setAge(_age);
    this.setPrenom(_prenom);
    initialize();
    }

    protected void initialize () {}



    /**
    * Return the unique identifier of this class
    * @hibernate.id
    * generator-class="native"
    * column="Id"
    */
    public java.lang.Integer getId () {
    return _id;
    }

    /**
    * Set the unique identifier of this class
    * @param _id the new ID
    */
    public void setId (java.lang.Integer _id) {
    this._id = _id;
    this.hashCode = Integer.MIN_VALUE;
    }


    /**
    * Return the value associated with the column: Nom
    */
    public java.lang.String getNom () {
    return _nom;
    }

    /**
    * Set the value related to the column: Nom
    * @param _nom the Nom value
    */
    public void setNom (java.lang.String _nom) {
    this._nom = _nom;
    }


    /**
    * Return the value associated with the column: Age
    */
    public java.lang.Integer getAge () {
    return _age;
    }

    /**
    * Set the value related to the column: Age
    * @param _age the Age value
    */
    public void setAge (java.lang.Integer _age) {
    this._age = _age;
    }


    /**
    * Return the value associated with the column: Prenom
    */
    public java.lang.String getPrenom () {
    return _prenom;
    }

    /**
    * Set the value related to the column: Prenom
    * @param _prenom the Prenom value
    */
    public void setPrenom (java.lang.String _prenom) {
    this._prenom = _prenom;
    }


    public boolean equals (Object obj) {
    if (null == obj) return false;
    if (!(obj instanceof hibernate.base.BaseTable)) return false;
    else {
    hibernate.base.BaseTable mObj = (hibernate.base.BaseTable) obj;
    if (null == this.getId() || null == mObj.getId()) return false;
    else return (this.getId().equals(mObj.getId()));
    }
    }


    public int hashCode () {
    if (Integer.MIN_VALUE == this.hashCode) {
    if (null == this.getId()) return super.hashCode();
    else {
    String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
    this.hashCode = hashStr.hashCode();
    }
    }
    return this.hashCode;
    }


    public String toString () {
    return super.toString();
    }

    }

  5. #25
    Membre Expert Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 53
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Par défaut
    Pas dans la classe table; mais lors de son appel.

    PS : n'oublie pas la balise code.

  6. #26
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Par défaut
    Merci beaucoup pour ton aide ça marche

Discussions similaires

  1. Problème de connexion à la base MYSQL via l'exécutable .JAR
    Par sam45 dans le forum Interfaces Graphiques en Java
    Réponses: 8
    Dernier message: 12/09/2008, 14h48
  2. [VB.net] Problème de connection à ma base MySQL
    Par WriteLN dans le forum Windows Forms
    Réponses: 3
    Dernier message: 02/01/2008, 17h14
  3. Problème : hibernate.connection.url jdbc:mysql
    Par doudou_angelus dans le forum Hibernate
    Réponses: 3
    Dernier message: 22/08/2007, 13h58
  4. pb de creation procedure Mysql via java
    Par metos00 dans le forum JDBC
    Réponses: 1
    Dernier message: 09/07/2007, 10h33
  5. se connecter à une base mysql via access
    Par Thom N2h dans le forum Access
    Réponses: 3
    Dernier message: 28/11/2005, 23h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo