Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
package join;
import java.sql.*;
import java.util.*;
import connection.*;
import java.util.ArrayList;

public class Course
{
	private String student_mail_add="",student_password="";
	Connection con=null;

ArrayList<string> course_id= new ArrayList<string>();
ArrayList<string> course_name = new ArrayList<string>();
	
public static ArrayList<string> convertStringArrayToArraylist(String[] strArr){
    ArrayList<string> stringList = new ArrayList<string>();
    for (String s : strArr) {
        stringList.add(s);
    }
    return stringList;
}	
	
	public void setStudent_mail_add(String student_mail_add) {
	this.student_mail_add=student_mail_add;
	}
	public String getStudent_mail_add()
	{
	return student_mail_add;
	}
	

	public void setStudent_password(String student_password) {
	this.student_password=student_password;
	}
	public String getStudent_password()
	{
	return student_password;
	}
	

	public void setCourse_id(String course_id) {
	this.course_id=course_id;
	}
	public String getCourse_id()
	{
	return course_id;
	}


	public void setCourse_name(String course_name) {
	this.course_name = course_name;
	}
	public String getCourse_name()
	{
	return course_name;
	}	

	public void fetch()
	{
		try
		{
		  Connect ob=new Connect();
		  con=ob.ctest();
		  PreparedStatement pst=con.prepareStatement("select * from course_join where course_join.student_mail_add=student_profile.student_mail_add=?");
		  pst.setString(1,student_mail_add);
		  ResultSet rs=pst.executeQuery();

		  while(rs.next()){
		   student_mail_add=rs.getString(1);
		  student_password=rs.getString(2);
		 
		  course_id.add(rs.getString(3));
		course_name.add(rs.getString(4));

			            }
		con.close();
		}
		catch(Exception e){}
	}
	

public int delete()
	{
	int t=0;
	try{
		Connect ob=new Connect();
		con=ob.ctest();
		PreparedStatement pst=con.prepareStatement("delete from course_join where student_mail_add=?");
		pst.setString(1,student_mail_add);
		
		t=pst.executeUpdate();
		con.close();
	}

	catch(Exception e){}
	return t;
	}

	}
Posted
Updated 16-Apr-14 5:28am
v2
Comments
CPallini 16-Apr-14 11:36am    
What is the offending line?

You might want to see more of your problem:
Java
   try{
    Connect ob=new Connect();
    con=ob.ctest();
    PreparedStatement pst=con.prepareStatement("delete from course_join where student_mail_add=?");
    pst.setString(1,student_mail_add);

    t=pst.executeUpdate();
    con.close();
}

catch(Exception e){
        // DO NOT SUPPRESS EXCEPTIONS!
        e.printStackTrace(); // or logging or anything, but never completely suppress them.
    }


And do you code manually or do you use a proper IDE?
The imports are manual. Please use an IDE, eclipse as also netbeans are free. They will guide you through that problem of not having the correct reference.



You might want to check on how to return an Array from an ArrayList:

Java
public static ArrayList<string> convertStringArrayToArraylist(String[] strArr){
    ArrayList<string> stringList = new ArrayList<string>();
    for (String s : strArr) {
        stringList.add(s);
    }
    return stringList;
}	</string></string></string>


http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html#toArray()[^]
 
Share this answer
 
v2
i do code manually..when i am compiling this on another computer of 64bits it gets compiled flawlessly.. i just cant seem to find the error in my computer
 
Share this answer
 
Comments
TorstenH. 17-Apr-14 8:17am    
Please use an IDE like Eclipse or Netbeans for programming. Both are free, both do help during programming.
Programming manually is seen by some as "learning it correctly" or "from bottom up".
As an experienced developer I can tell you that this is complete nonsense.
Do it the common way or play something different.
Shubhashish_Mandal 17-Apr-14 12:53pm    
Its Compiled !!! I can't believe this . "string" should be "String"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900