aspose file tools*
The moose likes JDBC and the fly likes Representing MilliSeconds in JDBC using Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Representing MilliSeconds in JDBC using Oracle" Watch "Representing MilliSeconds in JDBC using Oracle" New topic
Author

Representing MilliSeconds in JDBC using Oracle

Rajesh Kumar
Greenhorn

Joined: Nov 16, 2001
Posts: 28
Hai Friends
In my JDBC application i have to display date, and time along milliseconds.
I am using oracle database.
The below query will display date and time.
select to_char(d,'YYYY-MM-DD hh24:MI:SS') from datetest;

In Oracle can we show Milliseconds along with date and time ?
Just now i searched in oracle documentation.
and i didnot found the reference to represent milliseconds.
is it possiblt to represent the milli seconds in oracle ?
if anybody knows [query ]the format to show milliseconds also please tell me.
i need to represent milliseconds also in my application.
Thanks in advance
Yours
Rajesh
Jesper Ottosson
Ranch Hand

Joined: Mar 21, 2000
Posts: 51
Perhaps this is precisely what you're trying to avoid having to do, but if I were you, I would query the database for the raw date column, then use ResultSet.getDate() to get the date, and then format it manually.
Rajesh Kumar
Greenhorn

Joined: Nov 16, 2001
Posts: 28
Dear Jesper Ottosson,
Please tell me how to use ResultSet.getdate() and how to format the database data accordingly.
I am new to Java
Thanks in advance
Yours
Rajesh
Originally posted by Jesper Ottosson:
Perhaps this is precisely what you're trying to avoid having to do, but if I were you, I would query the database for the raw date column, then use ResultSet.getDate() to get the date, and then format it manually.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Rajesh:
I don't think the Oracle date datatype stores the time to the millisecond. From what I've read from my Oracle 8i manuals, there is no millisecond value stored in the database, so it wouldn't be possible to retrieve it. One work around could be to store a long value in an Oracle Number datatype that represents the java.util.Date in milliseconds.

This is a workaround if you can't find the date solution. You may want to post this question in the javaranch Oracle forum for an Oracle expert opinion.
Jamie
[This message has been edited by Jamie Robertson (edited December 10, 2001).]
[This message has been edited by Jamie Robertson (edited December 10, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Representing MilliSeconds in JDBC using Oracle