Bonjour,

Je suis encore débutant dans le développement.
Je développe un genre de formulaire qui doit renseigner la base de données.
Pour ma date j'utilise un composant de la librairie "JCalendar" sous format yyyy-MM-dd
Voici à quoi ressemble le "formulaire" :
Nom : Fenetre du formulaire.JPG
Affichages : 5069
Taille : 71,7 Ko
Voici mon code pour le bouton "Confirmer" :
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
    private void ButtonConfirmerDemandeActionPerformed(java.awt.event.ActionEvent evt) {                                                               
        Date ddate = DateChooser.getDate();
        String LoGeo = MenuDeroulant_LocaGeo.getSelectedItem().toString();
        String LiResto = MenuDeroulant_LieuxResto.getSelectedItem().toString();
        String eqpmtEns = MenuDeroulant_EquipmntEns.getSelectedItem().toString();
        String desAva = TxtArea_desAva.getText();
        String PrioAgent = Choix_PrioAgent.getSelectedItem().toString();
 
        if(ddate.equals("") || LoGeo.equals("") || LiResto.equals("") || eqpmtEns.equals("") || desAva.equals("") || PrioAgent.equals("")){
            JOptionPane.showMessageDialog(rootPane, "Certains champs sont vides", "Error", 1);
        }
        else {
            try{
                String query = "INSERT INTO avarie (`des_avarie`, `id_eqpmt` ,`prio_agent`, `date_creation`,`des_lieuDsetabliss`) values ( ?, (SELECT id_eqpmt FROM `equipement` WHERE des_eqpmt = '"+eqpmtEns+"' ),'"+PrioAgent+"','" +ddate+ "' , '"+LiResto+"' )" ;
                // INSERT INTO column_1 ( val_1, val_from_other_table ) VALUES('val_1', (SELECT  val_2 FROM table_2 WHERE val_2 = something))
 
 
                con = Connectionz.getConnection();
                pst = con.prepareStatement(query);
                pst.setString(1, desAva);
                pst.setDate(2, (java.sql.Date)(java.util.Date)ddate);
 
                pst.executeUpdate();
                pst.close();
 
                JOptionPane.showMessageDialog(null, "Enregistrement de la demande avec succès");
 
            }catch(Exception ex){
                ex.printStackTrace();
                JOptionPane.showMessageDialog(null, "Erreur d'insertion des données pour une demande d'intervention");
            }   
        }  
    }
Lors du clique me permettant d’exécuter la requête, j'obtiens ceci dans la console :
Mon Feb 04 14:22:24 HST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date
at mcappv3.DdeIntervAgent.ButtonConfirmerDemandeActionPerformed(DdeIntervAgent.java:260)
at mcappv3.DdeIntervAgent.access$000(DdeIntervAgent.java:19)
at mcappv3.DdeIntervAgent$1.actionPerformed(DdeIntervAgent.java:165)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2238)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2296)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4897)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4534)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4475)
at java.awt.Container.dispatchEventImpl(Container.java:2282)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
BUILD SUCCESSFUL (total time: 16 seconds)
L'erreur me renvoie sur cette ligne :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
pst.setDate(2, (java.sql.Date)(java.util.Date)ddate);
J'ai donc essayé ceci avec les import qu'il faut :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
pst.setDate(2, (java.sql.Date) ddate);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
pst.setDate(2, Date ddate);
Lorsque j'enlève cette ligne et que j'essaie, c'est cette ligne là que me renvoie l'erreur dans la console :
Comment puis-je faire pour que mon code et mon insertion de date dans ma base de de données fonctionnent ?

Merci à ceux qui pourront m'aider.