This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes problem retrieving date type from database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem retrieving date type from database." Watch "problem retrieving date type from database." New topic
Author

problem retrieving date type from database.

unni krishna
Ranch Hand

Joined: Jul 14, 2004
Posts: 39
I have come across a peculiar problem when I try to deploy ear in Weblogic Sun Solaris.

I am trying to fetch data from a table which has a field of type DATE.

I am using resultset.getObject(index) method to get the object for each column in the table. The issue starts here. In my windows system when I try to get the type of this object it returns java.sql.TimeStamp for the date column but when I deploy in UNIX it returns to me that object type of this column is java.sql.Date.

Can anyone explain why is this behaving differently in different platforms ?

I am using Weblogic 8.1 SP2 for the deployment in sun and windows OS.


Software Engineer (SCJP)<br />USTechnology, CA
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32312
    
213

Unni,
It looks like the drivers are giving you different types when you do not specify a specific type to return. If you call the getDate() or getTimestamp() method, you will consistenly get the type you are expecting.


[OCA 8 book] [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
unni krishna
Ranch Hand

Joined: Jul 14, 2004
Posts: 39
Thanks friend, it worked.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem retrieving date type from database.
 
jQuery in Action, 3rd edition