Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 13th, 2006, 5:37 PM   #1
Konnor
Newbie
 
Join Date: Aug 2005
Posts: 22
Rep Power: 0 Konnor is on a distinguished road
java, SQL, DB2

Not sure if anyone here will be able to offer help on these three combined but I'll see anyway.

I have a loop which looks like..

if (choice == 13)
{
	String SQLStatement = "SELECT * FROM FlightBooking";
	ResultSet rs = st.executeQuery(SQLStatement);
			   		
	while(rs.next())
        {			  
		String bookingID = rs.getString("BookingID");
			   			
		String SQLStatement3 = "UPDATE FlightBooking SET Duration = TIMESTAMPDIFF(8, CHAR(TIMESTAMP(CURRENT_TIMESTAMP)-TIMESTAMP((SELECT BookingTime FROM FlightBooking WHERE BookingID="+bookingID+"))))";
		st.executeUpdate(SQLStatement3);
			   			
		String bookingTime = rs.getString("BookingTime");
		String duration = rs.getString("Duration");
			   		
		System.out.println (bookingTime+" "+bookingID+" "+duration);
	 }
         rs.close();	
			   		
}

with the problem lines in red. What I am attempting to do is execute an update each time through the loop based on the new value of bookingID. The error im getting is 'The statement did not return a results set'.

Any thoughts?....
Konnor is offline   Reply With Quote
Old Mar 13th, 2006, 5:44 PM   #2
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 856
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
It looks like your SQL query isn't returning any results. You should make sure your database contains the entries described by your query, or modify your query to reflect the contents of your database. You should also test that the results returned by your query are valid before attempting to work with them.
titaniumdecoy is online now   Reply With Quote
Old Mar 14th, 2006, 9:52 AM   #3
Konnor
Newbie
 
Join Date: Aug 2005
Posts: 22
Rep Power: 0 Konnor is on a distinguished road
My query works at the Command editor, for individual rows, and I have data in the table, which is baffling me.

I'm trying to loop through to update the table for all rows. A single update seems to work fine. There must be other things to consider when using a loop.
Konnor is offline   Reply With Quote
Old Mar 14th, 2006, 1:04 PM   #4
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Try : System.out.println (bookingID);
Maybe something's wrong there.
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:34 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC