• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

SQL error

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi... I'm trying to retrieve the records whose check out dates match with the system date(A hotel room reservation software). But I'm getting the following error java.sql.SQLException: ORA-01722: invalid number

The CODE:::
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've added code tags to your post (it does look much better this way) - you can do so yourself, but avoid using other formatting tools (such as colors) in code, it is not supported.

What is the data type of the CUST_TO column? Based on the exception, I'd say it is a NUMBER, so it doesn't even make sense to compare it to a date.

If you really want to put in a date, you should use PreparedStatement. Actually, Rob has already told you so, so please follow the good advice when given to you. This page says why using PreparedStatement is critical, and the JDBC tutorial can help you doing so.

Please read both of these pages (and the complete JDBC tutorial, if you haven't done so yet) before you try to write another database code - it will help you avoid many database-related problems. Of course, if something is unclear to you in the tutorial, feel free to ask questions here - we'll happily answer questions from people that read tutorials

 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just one extra point to add to Martin's excellent advice:

You appear to be using your SYSTEM schema to hold these user tables. Do not do this. You should create a separate user schema for your application tables, and connect to the DB using that. The SYSTEM user has all kinds of extra privileges that you really do not want your application users to have access to. Also, until your run your application with the right user you cannot be sure you have set up access privileges etc properly.
 
expectation is the root of all heartache - shakespeare. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic