NullPointerException - mysql result... why?
well i will show u part of my code and maybe u will tell me what should i change...:/
Server:
publicclass Serverextends UnicastRemoteObjectimplements ServerFace{
Vector student;
public Vector getStudents()throws RemoteException{
try{
System.out.println("driver...");
Class.forName(driver).newInstance();
System.out.println("connecting to host...");
Connection con = DriverManager.getConnection(url,"usr","pswd");
System.out.println("query");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Student");
System.out.println("select");
while (rs.next()){
int id = rs.getInt("id");
String name = rs.getString("name");
String surname = rs.getString("surname");
System.out.println("" + id +" " + name +" " + surname +"\n");
student.add(new Student(id,name,surname));
System.out.println("student added");
}
rs.close();
stmt.close();
con.close();
}catch(Exception ex){
System.err.println("Exception: " + ex);
}
return student;
}
Client:
Vector student = server.getStudents();
Student class have 3 attributes (id, name, surname)
well here is server output:
driver...
connecting to host...
query
select
1 aaa bbb
Exception: java.lang.NullPointerException
so the error is in here:
student.add(new Student(id,name,surname));
thx for all answers

