• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error- help

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting the following error when i try to run my program. The program is just logging into a database and retrieving some records.I have a login method(to load the database) and a query method that queries the database and gets some records.
the query method is something like this


My main method passes query strings to the query method.
Main Method

I dont know why I am getting the following error.

java.sql.SQLException: ORA-00904: "MAR": invalid identifier
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at java.sql.SQLException.<init>(SQLException.java:43)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(Compiled Code)
at oracle.jdbc.ttc7.Oall7.receive(Compiled Code)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(Compiled Code)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(Compiled Code)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:796)
at Banniinsertch.query(Compiled Code)
at Banniinsertch.main(Compiled Code)

My inputs are movie_id and return_date (20-MAR-02)
When i try to run the query at the SQL prompt it works!!!
I am new to jdbc, so can anyone pls tell whats causing these errors and how to correct it.

thanks
sagarika
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you did copy your SQL to the editor and it worked, that makes me think that maybe you are using the wrong connection style. Are you using a thin client? Could you post your connection function?
I have only used a JDBC thin client and have used dates in the same format as you did with dateString = "date='02-MAR-02'" and it worked just fine for mine.
Another thought is making me wonder what type of field is your column in your Oracle database? DATE or DATETIME? I used straight up DATE (which of course returns a time anyways when you query it which you need to truncate off) when I used my example and it worked. If yours is DATETIME, your SQL editor might let you "fib" on your DATETIME entry and enter the default time where your JDBC connection might be more strict and require some sort of <systime> entry.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sagarika chinya:
I dont know why I am getting the following error.


java.sql.SQLException: ORA-00904: "MAR": invalid identifier

...
...

My inputs are movie_id and return_date (20-MAR-02)

When i try to run the query at the SQL prompt it works!!!

I am new to jdbc, so can anyone pls tell whats causing these errors and how to correct it.


thanks
sagarika



I have the exact same problem. An SQL query crashes if it is run by an EJB but it works perfectly well in the SQL client I am using? Did you find any solution on this?
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i am not sure ,but shouldnt the date which is used as input be
prefixed by to_date('',format).this converts the a value to a date type or a date from one format to another.
reply
    Bookmark Topic Watch Topic
  • New Topic