*
The moose likes JDBC and the fly likes error- help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "error- help " Watch "error- help " New topic
Author

error- help

sagarika chinya
Greenhorn

Joined: Oct 17, 2002
Posts: 11
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
Jeff Grant
Ranch Hand

Joined: Dec 19, 2001
Posts: 169
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.
Giri Onious
Greenhorn

Joined: Dec 13, 2004
Posts: 1
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?
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
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.
 
Don't get me started about those stupid light bulbs.
 
subject: error- help