• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retrieving a NUMBER column in resultset

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a column in Oracle db table

ACTIONFLAG NUMBER(19)

I need to retrieve this column from resultset and pass it in a java bean field of String dataType.

class Bean {

String actionFlag;

public setActionFlag(String af) {
...
}

}

From what I understand, ideally we should retrieve NUMBER columns using rs.getBigDecimal(),but i need to store the retrieved value in a String.

Which would be a better approach from a performance point of view.

1) bean.setActionFlag(rs.getString("ACTIONFLAG"))

or

2) bean.setActionFlaag(rs.getBigDecimal("ACTIONFLAG").setScale(0).toString());

Im using setScale(0) to remove decimal point because getBigDecimal returns 12.00 for a value 12 in table which i dont want. The column shall never hv any value with a decimal

or should i follow any other approach
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

... The column shall never hv any value with a decimal...


If you need only int values then whay don't you use INT as the column type?

And please UseRealWords when posting in the forums (eg: words like "hv" instead "have" make the reader confused).
 
Ashish Bassi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its not something i can change, the table structure is in production for sometime and db team isnt willing to change this.
So i was jus looking at performance improvement opportunities at java sidr
 
Whip out those weird instruments of science and probe away! I think it's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic