Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: JDBC Timestamp comparison
You didn't say what driver you're using...
This code seems to work for me:
c = d.connect("jdbc:oracle:thin:@joe:1521:S9205", props); System.out.println(c.getMetaData().getDriverVersion() ); Statement s = c.createStatement(); try{s.executeUpdate("drop table joe");} catch (Exception ignore){} s.executeUpdate("create table joe ( ID TIMESTAMP )"); s.executeUpdate("insert into joe values(SYSDATE)"); ResultSet r = s.executeQuery("select * from joe where ID >= CURRENT_TIMESTAMP - 12/24"); while (r.next()) System.out.println("we got " + r.getString(1) );
I get:
10.1.0.4.0
we got 2005-9-22.3.10. 17. 0
If I change it to r.getTimestamp(1).getTime() I get a typical long, like 1127387595000
Joe Weinstein at BEA Systems
suresh wrote:
> public void testQuery() {
> Connection con = null;
> Statement stmt = null;
> ResultSet resultSet = null;
> try {
> con = getConnection();
> stmt = con.createStatement();
> String sql = "select * from message_log where log_timestamp
>
>>= CURRENT_TIMESTAMP