• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with getObject()

 
Mahajan Bhupendra
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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..
if(row.getObject("question_no")!=null)
questionNo=((Integer)row.getObject("question_no")).intValue();
Since i want to check for null value also i don't eant to
use getInt() method..
What could be wrong??
Thanks in advance..
Bhupendra
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Bosun
 
Mahajan Bhupendra
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Bosun,
u r right i converted the code like this..
Object ob=row.getObject("question_no");
if(ob!=null)
questionNo=((Integer)ob).intValue();
but don't u think i m wasting one object???
BTW Thanx
Bhupendra
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Jamie

[This message has been edited by Jamie Robertson (edited October 11, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic