File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes problem with getObject() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem with getObject()" Watch "problem with getObject()" New topic

problem with getObject()

Mahajan Bhupendra
Ranch Hand

Joined: Dec 01, 2000
Posts: 118
i m using ms access as backend.
i am having a field "question_no" with data type Number
when i am trying to get the value with getObject() method of
ResultSet i am getting SQLException saying that : No Data Found
although i m able to get other data which is in terms of string
i m geeting the data using..
Since i want to check for null value also i don't eant to
use getInt() method..
What could be wrong??
Thanks in advance..

<B>Bhupendra Mahajan</B>
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
I think the problem is that you are trying to access the same column twice. You are calling getObject() twice. You can retrieve the data the first time, and then use the wasNull() emthod to check if the columns read was null. Check the API for the wasNull() method.


So much trouble in the world -- Bob Marley
Mahajan Bhupendra
Ranch Hand

Joined: Dec 01, 2000
Posts: 118
Yes Bosun,
u r right i converted the code like this..
Object ob=row.getObject("question_no");
but don't u think i m wasting one object???
BTW Thanx
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

why do you not want to use the getInt() method? maybe we can help you use a cleaner methodology for attaining your goal(and maybe not!). It just seems like there is a whole lot of stuff going on, when a method (getInt()) already exists.
my suggestion is:

Read the docs about ResultSet.wasNull() method to see if it can achieve the same goal

[This message has been edited by Jamie Robertson (edited October 11, 2001).]
I agree. Here's the link:
subject: problem with getObject()
It's not a secret anymore!