Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

what is "SQLException: Operation not allowed after ResultSet closed"

807606Mar 13 2007 — edited Mar 13 2007
i compile my program is no problem but when i run it it come out the error "SQLException: Operation not allowed after ResultSet closed"

what the error actually is?

here is my code:
import java.net.*;
import java.util.*;
import java.io.*;
import java.sql.*;
import java.util.Date;
import java.text.SimpleDateFormat;

public class attend{

public attend(String stud_id){
SimpleDateFormat sdf= new SimpleDateFormat("EEEE");
SimpleDateFormat sdf2= new SimpleDateFormat("hh:mm:ss");
Date c= new Date();
String day=sdf.format(c);
String time=sdf2.format(c);
System.out.println(day);
System.out.println(time);

try{
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	}
	catch (Exception E) {
	System.out.println("Unable to load driver.");
	E.printStackTrace();
	}
try{
		
		Connection C = DriverManager.getConnection("jdbc:mysql://localhost/attendance","root","");
			Statement S = C.createStatement();
 
			ResultSet rs = S.executeQuery("select "+ 

"student.student_id,student.student_name,student.email,lecturer.lecturer_name,course.course_desc,"+
"tsubject.tsubject_desc, tsubject.stime, tsubject.sday from student,stu_course,course_sub,course,tsubject,lecturer "+
"where student.student_id=stu_course.student_id AND stu_course.course_id=course_sub.course_id AND "+  

"course_sub.course_id=course.course_id AND "+
"course_sub.tsubject_id=tsubject.tsubject_id AND lecturer.lecturer_id=tsubject.lecturer_id AND student.student_id="+stud_id);
			
		ResultSetMetaData rsStruc = rs.getMetaData();
		while (rs.next()) {
			String student_id=rs.getString("student_id");
			String stud_name=rs.getString("Student_name");
			String email=rs.getString("email");
			String lec_name=rs.getString("lecturer_name");
			String course=rs.getString("course_desc");
			String subject=rs.getString("tsubject_desc");
			String stime=rs.getString("stime");
			String sday=rs.getString("sday");
			rs.close();
			C.close();
			}
	}
     catch (Exception E) {
	 System.out.println("SQLException: " + E.getMessage());
     }
	 
	}
public static void main(String args[])
	{
new attend("0503137");
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 10 2007
Added on Mar 13 2007
9 comments
4,230 views