Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

unable access null value from jtable  RSS feed

 
Sudhir Pawar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to store null values from jtable to array of variable, so i can execute and break while block successfully ?
jtable has 3 fields sr_no, tdesc,qty and sr_no has 1 to 100 values initially in jtable
and tdesc, qty table values are entered by user.

my code is:


problem given by this code is when null value occurs in jtable for column name tdesc it comes in catch block directly
so i am unable to store null value from jtable to variable tdesc and therefore while loop is not executing properly to break this loop based on if condition


so please give me solution so i can able store null values in variable.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't call the toString() method of a null value. If you do, you get the NullPointerException which you described in your post.

So don't do that. First test if the value is null. If it isn't, then you can continue to call its toString() method. If it is, then use whatever hard-coded string is suitable for your application.
 
Sudhir Pawar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks problem solved.........
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!