• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

ORA-01722 : invalid number

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why when I'm trying to insert a double or a long ( with insert into table in java ) in a column type number(20) always I obtained an error : "ORA-01722 : unvalid number"
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you share the code you are using to insert these values?
 
bahri sirine
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

stm0.executeUpdate("insert into test values ('"+i+"','"+j+"','"+k+"','"+t0+"')");

such that in the data base the first column is number(10), the second is number(20) the thirs is number(20) and the fourth is number (20)
 
Master Rancher
Posts: 4663
49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Print out your query before executing it.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Like Dave says, print out the actual SQL your Java code is trying to execute. Right now you do not know what is in the string that is being sent to the database, so you don't know what is causing the problem.
  • When you have the actual SQL string that is being sent to the database, execute that SQL directly via your SQL*Plus or SQL Developer client.
  • If you do not have a proper SQL client (e.g. SQL*Plus, SQL Developer, etc) then you do not have the tools to do your job properly, so install one ASAP and start using it to test your SQL before you put it into your Java code.
  • Incidentally, you don't need single-quotes around your values if they are numbers.
  • Finally, do not build SQL strings like this, but use prepared statements instead - see the Oracle JDBC docs.
  •  
    Your mind is under my control .... your will is now mine .... read this tiny ad
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
      Bookmark Topic Watch Topic
    • New Topic