Results 1 to 10 of 10
Thread: Help In JDBC
- 04-21-2011, 04:24 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 30
- Rep Power
- 0
Help In JDBC
I am making a program to search the student detail by enterering the roll number.In this I want to do if the student of entered roll number doest not exist in databse then it should diaplay a dialogue box The student of that roll number does not exist.
I have used
if(rs.wasNull())
display the dialogue box
else
display the details
but in each case else is executing but if is not why it is?
- 04-21-2011, 04:40 PM #2
Member
- Join Date
- Apr 2011
- Location
- UK
- Posts
- 10
- Rep Power
- 0
Could you post the code relating to the assignment of the rs (ResultSet I assume)?
No need for the whole code block, just the bits relating to 'rs'.
- 04-21-2011, 05:00 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 30
- Rep Power
- 0
Yes its result set
- 04-21-2011, 05:04 PM #4
Member
- Join Date
- Mar 2011
- Posts
- 30
- Rep Power
- 0
while(res.next())
{
String name=res.getString(1);
String city=res.getString(2);
String class1=res.getString(3);
if(res.wasNull())
{
tf1.setText("Does nOt EXist");
tf2.setText("Does nOt EXist");
tf3.setText("Does nOt EXist");
}
else
{
tf1.setText(name);
tf2.setText(city);
tf3.setText(class1);
}
}
- 04-21-2011, 05:11 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,393
- Blog Entries
- 7
- Rep Power
- 17
Read the API documentation for the ResultSet.wasNull() method; it doesn't do what you hope it does; hint, if there is no ResultSet.next() element no student matched the criteria ...
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 04-21-2011, 05:36 PM #6
Member
- Join Date
- Mar 2011
- Posts
- 30
- Rep Power
- 0
@JosAH could u please tell me what should i use and i have read wasNull method but i can not get its use could u please tell me this also..
Thanx
- 04-21-2011, 07:13 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,393
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 04-22-2011, 02:02 PM #8
Member
- Join Date
- Mar 2011
- Posts
- 30
- Rep Power
- 0
@JosAH thanx alot ...
- 04-22-2011, 03:40 PM #9
Senior Member
- Join Date
- Jan 2011
- Location
- Rizal Province, Philippiines
- Posts
- 167
- Rep Power
- 0
I think your problem is quite similar to my problem:
http://www.java-forums.org/database/...return-same-i-
need-refresh.html
There is bug on resultset
- 04-22-2011, 03:44 PM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,393
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
swt with Jdbc
By english in forum SWT / JFaceReplies: 0Last Post: 03-11-2011, 12:12 PM -
Jdbc
By KumbhaniMehul in forum Java ServletReplies: 1Last Post: 04-06-2010, 06:18 PM -
How to use JDBC Template classes to control basic JDBC processing and error handling
By Java Tip in forum Java TipReplies: 0Last Post: 04-01-2008, 10:17 AM -
Jdbc
By siwa in forum JDBCReplies: 4Last Post: 11-09-2007, 07:31 AM -
How to use JDBC Template classes to control basic JDBC processing and error handling
By JavaBean in forum Java TipReplies: 0Last Post: 09-28-2007, 12:56 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks