• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

getObject() method is not returning the proper result.

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i m using getObject(int paramInt) of ResultSet.

so when i m firing select sysdate from dual on database
and try to retrieve result with resultset.getObject(1);

i get different results for jdk1.5 and 1.6
for jdk1.5 i got only Date
and for jdk 1.6 i got date and time both
this is because while retrieving result in jdk 1.5 sysdate is object of Date at runtime
in jdk1.6 it is an object of timestamp
so is there any solution to change it in jdk1.5 as an object of timestamp because because want to use jdk 1.5 and also need result date with time both

do reply..........
thanks in advanced
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, meenakshi!

Using resultset.getTimeStamp() should work in both versions of Java. I'd suggest not to use the resultset.getObject() at all, always use getter for the concrete type instead. It will prevent this kind of surprises from happening.
 
meenakshi gavhale
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya i know i can use getTimestamp()

but i m retrieving different objects in my code with this getObject() so i can not use getTimestamp()
 
Martin Vashko
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems to me that you've generalized your code so much it's hurting you. I've done that in the past too, the best way out is to "ungeneralize" it a bit, in my opinion.

You could at least try to pass additional information about column types to your generalized method, and this method could use this information to call getTimestamp() instead of getObject(), if the column was DATE.
 
meenakshi gavhale
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya i did the same thing in code
but i thought something more efficient i have to do
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This very same thing was discussed yesterday, I made a very good suggestion in that thread, I am to lazy to type it again.
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic