I am having a timestamp column name DOWNLOAD_DATE in one database table named DOWNLOAD_TAB.
When I opened the Oracle SQL Developer the maximum date was “24.02.12 13:48:39,286000000”
select TO_CHAR (MAX(DOWNLOAD_DATE)) from DOWNLOAD_TAB
But the Query above returned me the date as “24.02.12 13:48:39,286”
Now I want to form a Query that will give me all the records after a certain date, But I am having that date available in java.util.Date.
I can not use the preparedstatement of java due to some framework constraints. I need to use the Statement class.
Would anyone please suggest me a way to do this in java using java.sql.Statement.
If you absolutely can’t use prepared statements, this should work. Format the date as you will, and then use TO_DATE in your sql statment using the same format. Oracle has a default format, but I prefer explicitly stating the format.
And that’s why a prepared statement is always preferred. As you can see, this code is ugly, error-prone, non-portable across databases, and open to sql injection attacks. And of course, prepared statement perform better.