aspose file tools*
The moose likes Java in General and the fly likes String to decimal? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "String to decimal?" Watch "String to decimal?" New topic
Author

String to decimal?

smitha verghese
Ranch Hand

Joined: Jun 21, 2003
Posts: 42
Hi
I am using Access database and i retrieve the contents which is in "string" from the Excel sheet using ExcelApi and put into the database Production with field "decimal" type !
like this
'"+Double.valueOf(rs.getString("LINE_COUNT")).doubleValue()+"','"+Double.valueOf(rs.getString("QUALITY")).doubleValue()+"'
But i get an error
java.lang.NullPointerException
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:9
90)
at java.lang.Double.valueOf(Double.java:172)
at _0002fLineCount_0002ejspLineCount_jsp_100._jspService(_0002fLineCount
_0002ejspLineCount_jsp_100.java:194)
Amol Desai
Ranch Hand

Joined: Jan 29, 2003
Posts: 82
Hi,
One of the getString() is returning null.
Better way would be to create a StringBuffer and append each rs.getString() to it.
You could then find which method returns null.
-Amol
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Why don't you just do
'"+rs.getString("LINE_COUNT")+"','"+rs.getString("QUALITY")+"'


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Since this isn't a performance question, I'm moving it to...um...Java in General (intermediate).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String to decimal?