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.
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.