This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Selecting * and specific sysdate format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Selecting * and specific sysdate format" Watch "Selecting * and specific sysdate format" New topic
Author

Selecting * and specific sysdate format

Patrick Ferguson
Ranch Hand

Joined: Jun 15, 2004
Posts: 30
Hello everyone.

I have a situation that I'm unfamiliar with and you guys always do a great job of helping out.

I'm writing a dynamic file sync system based on multiple tables in a database. These tables do NOT have the same column structure so I have to use "Select * from...", BUT I need one of the columns which is a date and is present in every table to come back with the date AND time. Currently it only comes back with the date(yyyy-mm-dd). I know the time is in there because I can see it. But when I select it into my java program it only has the date.

I know I could specifiy the columns and use a to_char function to get what I need, but you have to understand that I HAVE to use "Select * from..."

Any advice?

Thanks,

Patrick
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Patrick,
You can take advantage of a feature of JDBC: use ResultSet's getTimeStamp() method. This presumes you know which column number the date type is.

If not, you could probably figure it out from the database value and then call getTimeStamp(). Note that not all drivers support getting the same column twice, but most modern drivers should be ok.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923



http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Selecting * and specific sysdate format
 
Similar Threads
retrieve data from huge result set
external table
question on select
Fetching nK records in batch from client side?
SQL databases