Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resultset return null

 
Essam AbdelAziz
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
no it has acorrect data as i mentioned before


thank you
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you please post your code ??

Shailesh
 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you put your code snippet on the forum?





---------------------------------
Tip:Modesty is all virtue.
 
Parthasarathy balakrishnan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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,
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps that column was not part of the resultset.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic