Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ResultSet getObject question?

Posted on 2002-06-18
3
Medium Priority
?
761 Views
Last Modified: 2006-11-17
Hi, I am using  ResultSet.getObject method to
retrieve Oracle data through JDBC .  If I use
getString , it works.  But when I use getObject
, I got all null.  The data type in Oracle table is number, the responding java data type should be
BigDecimal.

Thanks.
Sean
0
Comment
Question by:xiaoxiangz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Expert Comment

by:kotan
ID: 7091497
why don't you use resultset.getBigDecimal().
0
 

Author Comment

by:xiaoxiangz
ID: 7092918
Well, in the future, the oracle table may contain
other type of fields, such date and integers.  So I want to use getObject().
0
 

Accepted Solution

by:
pothuganti_srinivas earned 450 total points
ID: 7105224
If you want a generic piece of code to work for different data types, you can do a small check before retreiving the data from result set using ResultSetMetaData.getColumnType() and code accordingly so that it does not break if some other data types are there in the database.

The code could be like this

if(resultSet.getMetaData().getColumnType(1)==java.sql.Types.DECIMAL){
   Object obj = resultSet.getBigDecimal(1);

}

......

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question