Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1258 connectés 

  FORUM HardWare.fr
  Programmation
  SQL/NoSQL

  Probleme portage mysql -> oracle (JDBC)

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Probleme portage mysql -> oracle (JDBC)

n°1057012
cooltwan
Posté le 22-04-2005 à 17:30:27  profilanswer
 

Salut,
j'ai un portage de mon appli java qui etait à la base basé sur mysql sous Oracle en cours.
 
Dans l'ensemble tout est ok (mis à part que j'avais dans le nom de mes colonnes des mots reservés oracle mais ça s'est arrangé depuis longtemps ...  :ange: à ma decharge cette liste est longue et presente des mots forts courants :o )
 
Mais subsite un souci, quand dans une requete je parametre un element via un setstring(toto)
si toto est la chaine vide (vide mais pas null) alors je me retrouve avec NULL dans ma base de donnée :( car y a un souci de norme avec Oracle ...  :cry:  
 
cf http://archives.postgresql.org/pgs [...] g00219.php
 
"
 
    Another problem when programming jdbc codes:
    "INSERT INTO person VALUES ('100')" //here, the field is an integer, but I insert as a string
    The above SQL can work well on both oracle and postgresql, but:
    "INSERT INTO person VALUES ('')"
    can work only on oracle but not work on postgresql. On oracle, a default value will be inserted, but postgresql will report an error.
 
Here the problem is that Oracle is not following the ANSI Standard. The standard says the '' = empty string which is how postgres correctly interprets it. In Oracle '' = null, which is a violation of the spec. Thus you are going to get different behavior in Oracle than in postgres. This code really should be doing the following which is in compliance with the sql spec and will work on both oracle and postgres:
INSERT INTO person VALUES(null)
"
 
ce qui est confirmé là
 
http://e-docs.bea.com/wls/docs70/f [...] tml#251569
 
"
Q. Why do I get an "ORA-01400: Cannot insert NULL into column name" when inserting a blank string?
 
A. This is a known Oracle issue. When inserting or updating a value for a varchar2, if you try to insert an empty string ("" ), Oracle interprets the value as NULL. If there is a NOT NULL restriction on the column in which you are inserting the value, the database throws the ORA-01400 error.  
"
 
donc dans pas mal de parametres je me retrouve avec des null partout :(
et à la lecture apres lors de get sur des resultats de requetes je me retrouve avec des null java ce qui va jusqu'à planter mon appli  :D  
 
Quelle solution propre adopter ? (j'en ai trouvé une qui consiste à rajouter dans la definition de mes tables oracle des valeurs par defaut systematiquement sur les champs en question mais je suis pas ravi :( )

mood
Publicité
Posté le 22-04-2005 à 17:30:27  profilanswer
 

n°1057139
cooltwan
Posté le 22-04-2005 à 19:26:32  profilanswer
 

[:flo850]

n°1058018
cooltwan
Posté le 23-04-2005 à 20:29:15  profilanswer
 

[:flo850]

n°1058046
cooltwan
Posté le 23-04-2005 à 20:51:15  profilanswer
 

Autre question comment inserer la chaine vide dans un champ type VARCHAR via jdbc sur une base oracle ?

n°1059972
cooltwan
Posté le 25-04-2005 à 16:05:47  profilanswer
 

up


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  SQL/NoSQL

  Probleme portage mysql -> oracle (JDBC)

 

Sujets relatifs
[VHDL] problème de simulation avec Quartus II[PostgreSQL] Triggers et JDBC
probleme : concatenation + ftp + dateprobleme de prog
[XSL] Problème de base ![MySQL] problème de left join (fusion de suppression)
MYSQL MARCHE PASEnum en Mysql
Pb Install mySQL 
Plus de sujets relatifs à : Probleme portage mysql -> oracle (JDBC)


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR