import java.rmi.*;
import java.rmi.server.*;
import java.sql.*;
import java.util.*;
class StudentImpl extends UnicastRemoteObject implements Student{
StudentImpl()throws RemoteException{}
public List<MyStudent> getStudents(){
List<MyStudent> list=new ArrayList<MyStudent>();
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
PreparedStatement ps=con.prepareStatement("select * from customer400");
ResultSet rs=ps.executeQuery();
while(rs.next()){
MyStudent s=new MyStudent();
s.rollNo(rs.getInt(1));
s.setFirstname(rs.getString(2));
s.setLastname(rs.getString(3));
s.setEmail(rs.getString(4));
s.setFeeBal(rs.getFloat(5));
list.add(s);
}
con.close();
}catch(Exception e){System.out.println(e);}
return list;
}
}
Comments
Leave a comment