• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving a NUMBER column in resultset

 
Ashish Bassi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic