aspose file tools*
The moose likes JDBC and the fly likes resultset return null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "resultset return null" Watch "resultset return null" New topic
Author

resultset return null

Essam AbdelAziz
Ranch Hand

Joined: Mar 10, 2007
Posts: 34
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

Joined: Aug 13, 2004
Posts: 1081

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


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Essam AbdelAziz
Ranch Hand

Joined: Mar 10, 2007
Posts: 34
no it has acorrect data as i mentioned before


thank you
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

could you please post your code ??

Shailesh
Baseet Ahmed
Ranch Hand

Joined: Dec 18, 2006
Posts: 224
Hi,

Can you put your code snippet on the forum?





---------------------------------
Tip:Modesty is all virtue.
Parthasarathy balakrishnan
Greenhorn

Joined: Apr 20, 2007
Posts: 14
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,


Thanks and Regards,<br />-------------------<br />Parthasarathy Balakrishnan,<br />Bangalore.
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

Perhaps that column was not part of the resultset.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: resultset return null
 
Similar Threads
help please
Problem Using PrintWriter class !
Sorting through Comparable(Very Urgent)
Stored proc not found...
Finding tab(\t) character in a sample java program.