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

Développement Web en Java Discussion :

problème d'insertion dans la base de données


Sujet :

Développement Web en Java

  1. #1
    Futur Membre du Club
    Inscrit en
    Avril 2010
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Avril 2010
    Messages : 5
    Points : 6
    Points
    6
    Par défaut problème d'insertion dans la base de données
    bonjour ,
    j'ai un projet de developpement d'une application web
    j'ai une problème lors d'inserer dans la base de donnée MySQL
    voilà mon code java:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    /*
     * Inscription.java
     *
     * Created on 25 avr. 2010, 15:15:53
     */
     
    package webapplication6;
    import mypackage.Etudiant;
    import com.sun.jsfcl.app.AbstractPageBean;
    import java.util.Date;
    import mypackage.Formation;
    import mypackage.NewHibernateUtil;
    import org.hibernate.Session;
    import org.hibernate.Transaction;
     
     
     
     
    /**
     * <p>Page bean that corresponds to a similarly named JSP page.  This
     * class contains component definitions (and initialization code) for
     * all components that you have defined on this page, as well as
     * lifecycle methods and event handlers where you may add behavior
     * to respond to incoming events.</p>
     *
     
     */
    public class Inscris extends AbstractPageBean {
     
     
     private String pwd;
         private String nom;
         private String prenom;
         private String civilite;
         private Date dateNaissance;
         private String lieuNaissance;
         private int cni;
         private int tel;
         private String adressePersonnel;
         private Integer codePostale;
         private String ville;
         private String pays;
         private String EMail;
         private String niveau;
         private Formation formation;
         private String login;
        private int idFormation;
     
        // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
     
        /**
         * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
         * This method is automatically generated, so any user-specified code inserted
         * here is subject to being replaced.</p>
         */
     
     
        // </editor-fold>
     
        /**
         * <p>Construct a new Page bean instance.</p>
         */
        public Inscris() {
     
        }
     
        /**
         * <p>Callback method that is called whenever a page is navigated to,
         * either directly via a URL, or indirectly via page navigation.
         * Customize this method to acquire resources that will be needed
         * for event handlers and lifecycle methods, whether or not this
         * page is performing post back processing.</p>
         *
         * <p>Note that, if the current request is a postback, the property
         * values of the components do <strong>not</strong> represent any
         * values submitted with this request.  Instead, they represent the
         * property values that were saved for this view when it was rendered.</p>
         */
        @Override
        public void init() {
            // Perform initializations inherited from our superclass
            super.init();
     
     
     
        }
     
        /**
         * <p>Callback method that is called after the component tree has been
         * restored, but before any event processing takes place.  This method
         * will <strong>only</strong> be called on a postback request that
         * is processing a form submit.  Customize this method to allocate
         * resources that will be required in your event handlers.</p>
         */
        @Override
        public void preprocess() {
        }
     
        /**
         * <p>Callback method that is called just before rendering takes place.
         * This method will <strong>only</strong> be called for the page that
         * will actually be rendered (and not, for example, on a page that
         * handled a postback and then navigated to a different page).  Customize
         * this method to allocate resources that will be required for rendering
         * this page.</p>
         */
        @Override
        public void prerender() {
        }
     
        /**
         * <p>Callback method that is called after rendering is completed for
         * this request, if <code>init()</code> was called (regardless of whether
         * or not this was the page that was actually rendered).  Customize this
         * method to release resources acquired in the <code>init()</code>,
         * <code>preprocess()</code>, or <code>prerender()</code> methods (or
         * acquired during execution of an event handler).</p>
         */
        @Override
        public void destroy() {
        }
     
        /**
         * <p>Return a reference to the scoped data bean.</p>
         *
         * @return reference to the scoped data bean
         */
        protected SessionBean1 getSessionBean1() {
            return (SessionBean1) getBean("SessionBean1");
        }
     
        /**
         * <p>Return a reference to the scoped data bean.</p>
         *
         * @return reference to the scoped data bean
         */
        protected RequestBean1 getRequestBean1() {
            return (RequestBean1) getBean("RequestBean1");
        }
     
        /**
         * <p>Return a reference to the scoped data bean.</p>
         *
         * @return reference to the scoped data bean
         */
        protected ApplicationBean1 getApplicationBean1() {
            return (ApplicationBean1) getBean("ApplicationBean1");
        }
     
     
     
     /*public void setdate(Date date)
        {
            this.dateNaiss=date;
        }
     public Date getdate()
     {
         return dateNaiss;
     }*/
        public String inscris() {
     
            Session session = NewHibernateUtil.getSessionFactory().getCurrentSession();
        Transaction transaction = null;
               try {
                   transaction = session.beginTransaction();
                 Etudiant contact = new Etudiant();
                 contact.setPwd(pwd);
                 contact.setAdressePersonnel(adressePersonnel);
                 contact.setCivilite(civilite);
                 contact.setCni(cni);
                 contact.setCodePostale(codePostale);
                 contact.setEMail(EMail);
                 contact.setIdformation(getIdFormation());
                 contact.setDateNaissance(null);
                 contact.setLieuNaissance(lieuNaissance);
                 contact.setLogin(login);
                 contact.setNom(nom);
                 contact.setPays(pays);
                 contact.setTel(tel);
                 contact.setVille(ville);
                 contact.setNiveau("ingeniere");
     
                 session.save(contact);
                 session.flush();
                 transaction.commit();
     
     
            } catch (Exception e) {if (transaction!= null)
            transaction.rollback();}
    return "index";
        }
     
        public String annule() {
     
            return "false";
        }
     
        /**
         * @return the pwd
         */
        public String getPwd() {
            return pwd;
        }
     
        /**
         * @param pwd the pwd to set
         */
        public void setPwd(String pwd) {
            this.pwd = pwd;
        }
     
        /**
         * @return the nom
         */
        public String getNom() {
            return nom;
        }
     
        /**
         * @param nom the nom to set
         */
        public void setNom(String nom) {
            this.nom = nom;
        }
     
        /**
         * @return the prenom
         */
        public String getPrenom() {
            return prenom;
        }
     
        /**
         * @param prenom the prenom to set
         */
        public void setPrenom(String prenom) {
            this.prenom = prenom;
        }
     
        /**
         * @return the civilite
         */
        public String getCivilite() {
            return civilite;
        }
     
        /**
         * @param civilite the civilite to set
         */
        public void setCivilite(String civilite) {
            this.civilite = civilite;
        }
     
        /**
         * @return the dateNaissance
         */
        public Date getDateNaissance() {
            return dateNaissance;
        }
     
        /**
         * @param dateNaissance the dateNaissance to set
         */
        public void setDateNaissance(Date dateNaissance) {
            this.dateNaissance = dateNaissance;
        }
     
     
        public String getLieuNaissance() {
            return lieuNaissance;
        }
     
     
        public void setLieuNaissance(String lieuNaissance) {
            this.lieuNaissance = lieuNaissance;
        }
     
        /**
         * @return the cni
         */
        public int getCni() {
            return cni;
        }
     
     
        public void setCni(int cni) {
            this.cni = cni;
        }
     
        /**
         * @return the tel
         */
        public int getTel() {
            return tel;
        }
     
        /**
         * @param tel the tel to set
         */
        public void setTel(int tel) {
            this.tel = tel;
        }
     
        /**
         * @return the adressePersonnel
         */
        public String getAdressePersonnel() {
            return adressePersonnel;
        }
     
        /**
         * @param adressePersonnel the adressePersonnel to set
         */
        public void setAdressePersonnel(String adressePersonnel) {
            this.adressePersonnel = adressePersonnel;
        }
     
        /**
         * @return the codePostale
         */
        public Integer getCodePostale() {
            return codePostale;
        }
     
        /**
         * @param codePostale the codePostale to set
         */
        public void setCodePostale(Integer codePostale) {
            this.codePostale = codePostale;
        }
     
        /**
         * @return the ville
         */
        public String getVille() {
            return ville;
        }
     
        /**
         * @param ville the ville to set
         */
        public void setVille(String ville) {
            this.ville = ville;
        }
     
        /**
         * @return the pays
         */
        public String getPays() {
            return pays;
        }
     
        /**
         * @param pays the pays to set
         */
        public void setPays(String pays) {
            this.pays = pays;
        }
     
        /**
         * @return the EMail
         */
        public String getEMail() {
            return EMail;
        }
     
        /**
         * @param EMail the EMail to set
         */
        public void setEMail(String EMail) {
            this.EMail = EMail;
        }
     
        /**
         * @return the niveau
         */
        public String getNiveau() {
            return niveau;
        }
     
        /**
         * @param niveau the niveau to set
         */
        public void setNiveau(String niveau) {
            this.niveau = niveau;
        }
     
        /**
         * @return the idformation
         */
        public Formation getIdformation() {
            return formation;
        }
     
        /**
         * @param idformation the idformation to set
         */
        public void setIdformation(Formation formation) {
            this.formation = formation;
        }
     
        /**
         * @return the login
         */
        public String getLogin() {
            return login;
        }
     
        /**
         * @param login the login to set
         */
        public void setLogin(String login) {
            this.login = login;
        }
     
        /**
         *
         */
        @Override
        public void afterRenderResponse() {
     
        }
     
        /**
         * @return the idFormation
         */
        public int getIdFormation() {
            return idFormation;
        }
     
        /**
         * @param idFormation the idFormation to set
         */
        public void setIdFormation(int idFormation) {
            this.idFormation = idFormation;
        }
     
     
     
     
     
    }

  2. #2
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Citation Envoyé par malek21 Voir le message
    bonjour ,
    j'ai un projet de developpement d'une application web
    j'ai une problème lors d'inserer dans la base de donnée MySQL

    Ma boule de cristal est en rade et mes cartes de tarot sont en révision, alors dit nous "quel problème" ?

  3. #3
    Futur Membre du Club
    Inscrit en
    Avril 2010
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Avril 2010
    Messages : 5
    Points : 6
    Points
    6
    Par défaut problème d'insertion dans la base de donnée en utilisant Hibernate
    bonjour
    désolé par ce que j ai pas préciser mon problème
    le problème est:
    lorsque j'essai d'inserer des champs dans la page web,après deboguer mon application ,il m'apparu l'exception suivante:
    Exception Handler
    Exception Details: javax.el.PropertyNotFoundException
    Target Unreachable, identifier 'Iscris' resolved to null
    Possible Source of Error:
    Class Name: com.sun.el.parser.AstValue
    File Name: AstValue.java
    Method Name: getTarget
    Line Number: 131

  4. #4
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    La propriété ou le bean "Iscris" que tu veux utiliser dans ta page web est null, donc impossible d'accéder à des sous propriétés de ce non objet. Je ne vois d'ailleurs aucun rapport avec le code que tu as posté.

Discussions similaires

  1. problême d'insertion dans la base de données
    Par tchimou dans le forum Bases de données
    Réponses: 5
    Dernier message: 21/03/2007, 16h33
  2. Problème d'insertion dans une base de donnèes
    Par atout dans le forum Administration
    Réponses: 14
    Dernier message: 27/12/2006, 07h07
  3. [paradox7] Problème d'insertion dans la base de données
    Par mouna201 dans le forum Bases de données
    Réponses: 4
    Dernier message: 01/02/2006, 09h47
  4. problème d'insertion dans une base de données
    Par belmansour tidjani dans le forum JDBC
    Réponses: 7
    Dernier message: 18/01/2006, 22h13
  5. [Hibernate] problème d'insertion dans la base de données
    Par Willy7901 dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 18/08/2005, 13h19

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