Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with getObject() method of ResultSet

 
dimpsonu arora
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using getObject instead of, say, getTimestamp?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic