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

SQL Oracle Discussion :

java.sql.SQLException: ORA-00933: la commande SQL ne se termine pas correctement


Sujet :

SQL Oracle

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Juillet 2007
    Messages
    57
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Juillet 2007
    Messages : 57
    Points : 38
    Points
    38
    Par défaut java.sql.SQLException: ORA-00933: la commande SQL ne se termine pas correctement
    Salut
    j'ai un problème avec l'instruction UPDATE. En fait je fais une mis à jour dans une de mes tables voici ma fonction qui fait la modification

    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
     
     public void MiseaJourControleur(String Matricule, String CertificatMed, String DateQualif1, String NomAgent, String PrenomAgent, 
                                         String Sexe, String DateNaissance, String Nationalite, String Fonction, String DateRecrutement, 
                                         String Niveau, String DateRetraite) throws SQLException, Exception
            {
                conex = new Connexion();
                con = conex.getConn();
                Statement stmt = con.createStatement();
                int resupdtagent, nivo = 0;
     
                java.sql.Date datenaissance = null;
                java.sql.Date daterecrutement = null;
                java.sql.Date dateretraite = null;
                java.sql.Date certificatmed = null;
                java.sql.Date datequalif1 = null;
     
                SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
     
                datenaissance = new java.sql.Date(sdf.parse(DateNaissance).getTime()); 
                daterecrutement = new java.sql.Date(sdf.parse(DateRecrutement).getTime()); 
                dateretraite = new java.sql.Date(sdf.parse(DateRetraite).getTime()); 
                certificatmed = new java.sql.Date(sdf.parse(CertificatMed).getTime());
                datequalif1 = new java.sql.Date(sdf.parse(DateQualif1).getTime());
     
     
                // Initialisation Niveau Anglais
                if(Niveau != null)   nivo = Integer.parseInt(Niveau);
     
                String updtagent = "UPDATE CONTROLEUR"+
                                   " SET  CERTIFICATMED = "+certificatmed+ ", DATEQUALIFICATION1 = "+datequalif1+", NOMAGENT = "+NomAgent+
                                       ", PRENOMAGENT = "+PrenomAgent+", SEXE = "+Sexe+", DATENAISSANCE = "+datenaissance+
                                       ", NATIONALITE = "+Nationalite+", FONCTION = "+Fonction+", NIVEAU = "+nivo+
                                       ", DATERECRUTEMENT = "+daterecrutement+", DATERETRAITE = "+dateretraite+
                                  " WHERE MATRICULE = "+Matricule;
     
               resupdtagent = stmt.executeUpdate(updtagent);
     
             con.commit();
     
                System.out.println("Mise à jour OK!!");
            }// Fin MiseaJourControleur
    j'appelle cette fonction dans une page jsp et lorsque j'execute cette page j'ai l'erreur suivante
    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
     
    javax.servlet.ServletException: ORA-00933: la commande SQL ne se termine pas correctement
     
    	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
    	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
    	org.apache.jsp.ficheagent_jsp._jspService(ficheagent_jsp.java:608)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
     
     
    cause mère 
     
    java.sql.SQLException: ORA-00933: la commande SQL ne se termine pas correctement
     
    	oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    	oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    	oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    	oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
    	oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
    	oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:946)
    	oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
    	oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1614)
    	oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1579)
    	gestionformation.Controleur.MiseaJourControleur(Controleur.java:184)
    	org.apache.jsp.ficheagent_jsp._jspService(ficheagent_jsp.java:278)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
    je ne vois pas l'erreur que j'ai pu faire dans ma requête de mise à jour!! Quelqu'un voit il où j'ai pu péché?
    Merci d'avance!

  2. #2
    Membre chevronné Avatar de Garuda
    Homme Profil pro
    Chef de projet / Urbaniste SI
    Inscrit en
    Juin 2007
    Messages
    1 285
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Chef de projet / Urbaniste SI
    Secteur : Bâtiment

    Informations forums :
    Inscription : Juin 2007
    Messages : 1 285
    Points : 2 071
    Points
    2 071
    Par défaut
    Faire afficher la chaine requête aprés construction (System.out.println updtagent) pour analyse.
    C'est encore le plus simple !
    Garuda गरूड
    Brahmâ la Guerre et Vishnu la Paix

    Oracle 12C R2 - Forms11GR2 - Toad 12 - sharePoint 2010

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Juillet 2007
    Messages
    57
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Juillet 2007
    Messages : 57
    Points : 38
    Points
    38
    Par défaut
    Voici la chaine affiché après construction :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    UPDATE CONTROLEUR 
    SET  CERTIFICATMED = 2007-06-02, 
    DATEQUALIFICATION1 = 2001-01-20, 
    NOMAGENT = toto, 
    PRENOMAGENT = tata, 
    SEXE = H, 
    DATENAISSANCE = 1974-06-13, 
    NATIONALITE = malais, 
    FONCTION = null, 
    NIVEAU = 4, DATERECRUTEMENT = 2000-03-01, 
    DATERETRAITE = 2029-05-30 
    WHERE MATRICULE = 369
    je ne vois toujours pas d'anomalies!
    PS: le champ FONCTION n'est pas obligatoire.

  4. #4
    Membre chevronné Avatar de Garuda
    Homme Profil pro
    Chef de projet / Urbaniste SI
    Inscrit en
    Juin 2007
    Messages
    1 285
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Chef de projet / Urbaniste SI
    Secteur : Bâtiment

    Informations forums :
    Inscription : Juin 2007
    Messages : 1 285
    Points : 2 071
    Points
    2 071
    Par défaut
    Il faut que ta requète ressemble à ca
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    UPDATE controleur
       SET certificatmed = to_date('2007-06-02','YYYY-MM-DD'),
           datequalification1 = to_date('2001-01-20','YYYY-MM-DD'),
           nomagent = 'toto',
           prenomagent = 'tata',
           sexe = 'h',
           datenaissance = to_date('1974-06-13','YYYY-MM-DD'),
           nationalite = 'malais',
           fonction = NULL,
           niveau = 4,
           daterecrutement = to_date('2000-03-01','YYYY-MM-DD'),
           dateretraite = to_date('2029-05-30','YYYY-MM-DD')
     WHERE matricule = 369
    La, c'est la manière brute.
    Sinon tu peux faire du 'binding' de variable + des prepared statement (faire une recherche)
    C'est beaucoup plus propre et efficace (réutilisation du curseur, 1 seul parsing)
    Garuda गरूड
    Brahmâ la Guerre et Vishnu la Paix

    Oracle 12C R2 - Forms11GR2 - Toad 12 - sharePoint 2010

  5. #5
    Membre chevronné Avatar de Garuda
    Homme Profil pro
    Chef de projet / Urbaniste SI
    Inscrit en
    Juin 2007
    Messages
    1 285
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Chef de projet / Urbaniste SI
    Secteur : Bâtiment

    Informations forums :
    Inscription : Juin 2007
    Messages : 1 285
    Points : 2 071
    Points
    2 071
    Garuda गरूड
    Brahmâ la Guerre et Vishnu la Paix

    Oracle 12C R2 - Forms11GR2 - Toad 12 - sharePoint 2010

  6. #6
    Nouveau membre du Club
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Juillet 2007
    Messages
    57
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Juillet 2007
    Messages : 57
    Points : 38
    Points
    38
    Par défaut
    Merci Garuda j'ai essayé avec les PreparedStatement ça marche sans problème.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 7
    Dernier message: 19/05/2011, 19h13
  2. ORA-00933: la commande SQL ne se termine pas correctement
    Par DeveloppeurWeb dans le forum ASP
    Réponses: 2
    Dernier message: 12/04/2010, 12h56
  3. Réponses: 1
    Dernier message: 08/02/2008, 17h32
  4. ORA-00933 la commande SQL ne se termine pas correctement
    Par habasque dans le forum Sql*Plus
    Réponses: 1
    Dernier message: 09/12/2006, 14h41
  5. Réponses: 4
    Dernier message: 25/01/2006, 18h25

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