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 :

ORA-01858: Caractère non numérique trouvé à la place d'un caractère numérique


Sujet :

JDBC Java

  1. #1
    Membre à l'essai
    Homme Profil pro
    Analyste d'exploitation
    Inscrit en
    Février 2018
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Analyste d'exploitation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2018
    Messages : 15
    Points : 10
    Points
    10
    Par défaut ORA-01858: Caractère non numérique trouvé à la place d'un caractère numérique
    Bonjour,

    j'ai un soucis avec mon application, c'est que j'ai migré la base de donnée vers RACV12 et lorsque j'ai connécté mon application a la base j'ai eu un problème avec la liste des demande :

    il m'affiche le message d'erreur : ListeDemandes - java.sql.SQLException: ORA-01858: Caractère non numérique trouvé à la place d'un caractère numérique

    et la page web normalement qui doit afficher la liste des demandes s'affiche vide,
    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
    public void buildListe(){
            listDemandes.clear();
            sql = "SELECT S.IDSTATUT, NOMSTATUT, IDTRAJET, TO_CHAR(DATETRAJET,'DD/MM/YYYY') AS DT, LIBELLEDEPART, LIBELLEARRIVEE, NBVOYAGEURS, BENEFICIAIREPRINCIPALTRAJET, NOMDEMANDEUR FROM TRAJET T, STATUT S WHERE T.IDSTATUT = S.IDSTATUT AND TO_DATE(DATETRAJET,'dd/mm/yy') >= TO_DATE(SYSDATE,'dd/mm/yy')"; 
            if(owner != null)
                sql = sql + " AND NOMDEMANDEUR = '"+ owner +"'";
            if(idStatut != null)
                sql = sql + " AND S.IDSTATUT = "+ idStatut;
            else
                sql = sql + " AND (S.IDSTATUT = 1 OR S.IDSTATUT = 2 OR S.IDSTATUT = 4 OR S.IDSTATUT = 5)";
            if(!date.equalsIgnoreCase("all")){
                sql += " AND DATETRAJET = TO_DATE('"+date+"','dd/mm/yyyy')";
            }
            String req = sql +" ORDER BY "+colTri+" "+typeTri;
            try{
                 conn = ds.getConnection();
                 java.sql.Statement stmt = conn.createStatement();
                 ResultSet rs = stmt.executeQuery(req); 
                 while(rs.next()){                
                    String nomStatut = rs.getString("NOMSTATUT");
                    String idTrajet = rs.getString("IDTRAJET");
                    String dateTrajet = rs.getString("DT");
                    String libelleDepart = rs.getString("LIBELLEDEPART");
                    String libelleArrivee = rs.getString("LIBELLEARRIVEE");
                    String nbVoyageurs = rs.getString("NBVOYAGEURS");
                    String benefPrincipal = rs.getString("BENEFICIAIREPRINCIPALTRAJET");
                    String nomDemandeur = rs.getString("NOMDEMANDEUR");
                    ArrayList vTrajet = new ArrayList();
                    //listDemandes.add(vTrajet);
                    InfosTrajetLite t = new InfosTrajetLite();
                    t.setIdTrajet(rs.getInt("IDTRAJET"));
                    listDemandes.add(t);
                 }
                 rs.close();
                 stmt.close();
                 conn.close();
            }
            catch(Exception e){
                try{ if(!conn.isClosed() && conn != null) conn.close();} catch(Exception ex){_logger.fatal(ex);}
                _logger.fatal(e);            
            }        
        }

    J'ai testé la requet sql sur sqlDEV il affiche le résultat,

  2. #2
    Expert confirmé
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 274
    Points : 4 141
    Points
    4 141
    Par défaut
    Ca ne répond pas directement à ton problème mais il faut utiliser le positionnement des paramètres proposé par l'API au lieu de concaténer des valeurs, tu t'exposes à ce genre d'erreur et à des injections SQL.

  3. #3
    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
    tu peux nous afficher la requête sql générée?

  4. #4
    Membre à l'essai
    Homme Profil pro
    Analyste d'exploitation
    Inscrit en
    Février 2018
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Analyste d'exploitation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2018
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    voila la requête sql que j'ai mis :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SELECT S.IDSTATUT, NOMSTATUT, IDTRAJET, TO_CHAR(DATETRAJET,'DD/MM/YYYY') AS DT, LIBELLEDEPART, LIBELLEARRIVEE, NBVOYAGEURS, BENEFICIAIREPRINCIPALTRAJET, NOMDEMANDEUR FROM TRAJET T, STATUT S WHERE T.IDSTATUT = S.IDSTATUT AND TO_DATE(DATETRAJET,'dd/mm/yy') >= TO_DATE(SYSDATE,'dd/mm/yy')
    elle marche sur SQLDEV j'ai le résultat normal

  5. #5
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 551
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 551
    Points : 21 607
    Points
    21 607
    Par défaut
    Euh oui mais tu fais quoi des if qu'il y a après ?

    Il faut montrer la requête générée avec les if, pas sans eux.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  6. #6
    Membre à l'essai
    Homme Profil pro
    Analyste d'exploitation
    Inscrit en
    Février 2018
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Analyste d'exploitation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2018
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    voici la requête :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SELECT S.IDSTATUT, NOMSTATUT, IDTRAJET, TO_CHAR(DATETRAJET,'DD/MM/YYYY') AS DT, LIBELLEDEPART, LIBELLEARRIVEE, NBVOYAGEURS, BENEFICIAIREPRINCIPALTRAJET, NOMDEMANDEUR FROM TRAJET T, STATUT S WHERE T.IDSTATUT = S.IDSTATUT AND TO_DATE(DATETRAJET,'dd/mm/yy') >= TO_DATE(SYSDATE,'dd/mm/yy') AND (S.IDSTATUT = 1 OR S.IDSTATUT = 2 OR S.IDSTATUT = 4 OR S.IDSTATUT = 5) ORDER BY DATETRAJET DESC

  7. #7
    Membre à l'essai
    Homme Profil pro
    Analyste d'exploitation
    Inscrit en
    Février 2018
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Analyste d'exploitation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2018
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    j'ai ajouté des if pour localiser l'anomalie :
    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
      public void buildListe(){
            listDemandes.clear();
            sql = "SELECT S.IDSTATUT, NOMSTATUT, IDTRAJET, TO_CHAR(DATETRAJET,'DD/MM/YYYY') AS DT, LIBELLEDEPART, LIBELLEARRIVEE, NBVOYAGEURS, BENEFICIAIREPRINCIPALTRAJET, NOMDEMANDEUR FROM TRAJET T, STATUT S WHERE T.IDSTATUT = S.IDSTATUT AND TO_DATE(DATETRAJET,'dd/mm/yy') >= TO_DATE(SYSDATE,'dd/mm/yy')"; 
            if(owner != null)
                sql = sql + " AND NOMDEMANDEUR = '"+ owner +"'";
            if(idStatut != null)
                sql = sql + " AND S.IDSTATUT = "+ idStatut;
            else
                sql = sql + " AND (S.IDSTATUT = 1 OR S.IDSTATUT = 2 OR S.IDSTATUT = 4 OR S.IDSTATUT = 5)";
            if(!date.equalsIgnoreCase("all")){
                sql += " AND DATETRAJET = TO_DATE('"+date+"','dd/mm/yyyy')";
            }
            String req = sql +" ORDER BY "+colTri+" "+typeTri;
            try{
     
                 conn = ds.getConnection();
                 if (conn != null) {System.out.println("conn ok");
     
                 }else {System.out.println("conn Nok");}
     
                 java.sql.Statement stmt = conn.createStatement();
                 if (stmt != null) {System.out.println("stmt ok");
     
                 }else {System.out.println("stmt Nok");}
     
                 System.out.println(req);
                 ResultSet rs = stmt.executeQuery(req);
                 if(rs !=null) { System.out.println("rs ok");
                 }else {  System.out.println("rs Nok"); }
     
     
                 while(rs.next()){                
                    String nomStatut = rs.getString("NOMSTATUT");
                    String idTrajet = rs.getString("IDTRAJET"); 
                    String dateTrajet = rs.getString("DT");
                    String libelleArrivee = rs.getString("LIBELLEARRIVEE");
                    String libelleDepart = rs.getString("LIBELLEDEPART");
                    String nbVoyageurs = rs.getString("NBVOYAGEURS");
                    String benefPrincipal = rs.getString("BENEFICIAIREPRINCIPALTRAJET");
                    String nomDemandeur = rs.getString("NOMDEMANDEUR");
     
     
     
     
     
                    //System.out.println(idTrajet);                
                    ArrayList vTrajet = new ArrayList();
                    //listDemandes.add(vTrajet);
                    InfosTrajetLite t = new InfosTrajetLite();
                    t.setIdTrajet(rs.getInt("IDTRAJET"));
                    listDemandes.add(t);
                    System.out.println("rs vide");
     
                 }
                 rs.close();
                 stmt.close();
                 conn.close();
            }
            catch(Exception e){
            	System.out.println("connexion ko");
     
                try{ if(!conn.isClosed() && conn != null) conn.close();} catch(Exception ex){_logger.fatal(ex);}
                _logger.fatal(e);            
            }        
        }
    Voici le résultat :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    conn ok
    stmt ok
    SELECT S.IDSTATUT, NOMSTATUT, IDTRAJET, TO_CHAR(DATETRAJET,'DD/MM/YYYY') AS DT, LIBELLEDEPART, LIBELLEARRIVEE, NBVOYAGEURS, BENEFICIAIREPRINCIPALTRAJET, NOMDEMANDEUR FROM TRAJET T, STATUT S WHERE T.IDSTATUT = S.IDSTATUT AND TO_DATE(DATETRAJET,'dd/mm/yy') >= TO_DATE(SYSDATE,'dd/mm/yy') AND (S.IDSTATUT = 1 OR S.IDSTATUT = 2 OR S.IDSTATUT = 4 OR S.IDSTATUT = 5) ORDER BY DATETRAJET DESC
    connexion ko
    02/03 01:25:44[FATAL] eddt.ListeDemandes - java.sql.SQLException: ORA-01858: Caractère non numérique trouvé à la place d'un caractère numérique

  8. #8
    Expert confirmé
    Homme Profil pro
    Inscrit en
    Septembre 2006
    Messages
    2 937
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 2 937
    Points : 4 358
    Points
    4 358

  9. #9
    Membre à l'essai
    Homme Profil pro
    Analyste d'exploitation
    Inscrit en
    Février 2018
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Analyste d'exploitation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2018
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    Bonjour,

    Merci à tous pour votre aide, j'ai pu résoudre le soucis. j'ai modifié la requête SQL, j'ai enlevé les TO_DAT et TO_CHAR et ça a fonctionné

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

Discussions similaires

  1. Réponses: 4
    Dernier message: 14/12/2015, 11h29
  2. [PL/SQL] Supprimer les caractères non numériques
    Par Oliveuh dans le forum PL/SQL
    Réponses: 6
    Dernier message: 25/06/2015, 12h13
  3. Réponses: 2
    Dernier message: 16/05/2011, 18h43
  4. Ora-01858 caractère non numérique
    Par pascalT dans le forum SQL
    Réponses: 15
    Dernier message: 03/09/2008, 11h30
  5. Réponses: 1
    Dernier message: 03/06/2008, 09h05

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