• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

resultset return null

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All
i'm trying tp read Some Date From My table in DB

the table consist of 2 coulmns
Name1,Name2

when i try to get Name1 like this
String Name1=resultset.getString("Name1");
it will return Name1 with out any problems
but when i try to get Name2 like this
String Name2=resultset.getString("Name2");

it will return null although name2 is contain "essam" in DB

so what is the problem...?


thank you
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your question has nothing to do with JSP, you should post it in JDBC forum.

anyways back to your problem, could you please post your code here, either there is some problem with code or column name2 does not have data.

Thanks,
Shailesh
 
Essam AbdelAziz
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no it has acorrect data as i mentioned before


thank you
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could you please post your code ??

Shailesh
 
Ranch Hand
Posts: 225
Spring Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you put your code snippet on the forum?





---------------------------------
Tip:Modesty is all virtue.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i try to get Name1 like this
String Name1=resultset.getString("Name1");
it will return Name1 with out any problems
but when i try to get Name2 like this
String Name2=resultset.getString("Name2");

it will return null although name2 is contain "essam" in DB

from your code i can suggest
that:

check for the following changes:

1.check for the column name in the database that it is like
Same us you have give in the getString method();

2.else do not struck with that please put the code
rs.getString(2) if you want the value of 2nd column

example code:
System.out.println(rs.getString(1) +"\t"+rs.getString(2));

by,
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps that column was not part of the resultset.
 
machines help you to do more, but experience less. Experience this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic