jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes Problem with getObject() method of ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with getObject() method of ResultSet" Watch "Problem with getObject() method of ResultSet" New topic
Author

Problem with getObject() method of ResultSet

dimpsonu arora
Ranch Hand

Joined: Aug 13, 2003
Posts: 51
Hi,
I have got a major problem. Please help.
I am using Oracle9i with Weblogic 8.1 SP4. I am using:
oracle.jdbc.driver.OracleDriver drivers.
URL starts with: jdbc racle:thin
In database, I am having two fields with data type "Date" and "Number".
Now, When I am fetching data from database, I am using getObject() method of ResultSet. As per my knowledge, This method should return the object of Date and Object of Integer in java types. After fetching object, In my java class, I am casting the values as follows:

BigDecimal bd=(BigDecimal)resultset.getObject("ProjectID");
//On above line I tried instanceof operator to check if it returns object of BigDecimal. It returns me true. Casting working fine here.

Timestamp ts=(Timestamp)resultset.getObject("ProjectStartDate");
//On above line I tried instanceof operator to check if it returns object of Timestamp. It returns me false. It is returning the object of class Object. Casting is not working here. It is giving me ClassCastException at runtime.

Can somebody suggest why it is happening.?
The code was working fine with weblogic 8.1 SP2. Is there some problem of drivers OR something else?
Please help as it is very urgent. Thanks in Advance.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
i think you can easily find out this issue by your-self !

look at what type of object the method return to you
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Why are you using getObject instead of, say, getTimestamp?


There is no emoticon for what I am feeling!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with getObject() method of ResultSet