How do we provide security to RMI classes? Write a program to implement Simple Student database application using RMI. Remote client consist of GUI for performing different database operations (For ex. Insert, delete, update) and retrieving data through RMI.
import java.rmi.*;
import java.rmi.server.*;
import java.sql.*;
import java.util.*;
class StudentAccountImp extends UnicastRemoteObject implements Bank{
StudentAccountImp()throws RemoteException{}
public List<StudentAccount> getCustomers(){
List<StudentAccount> list=new ArrayList<StudentAccount>();
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()){
StudentAccount c=new StudentAccount();
c.setAcc_no(rs.getInt(1));
c.setFirstname(rs.getString(2));
c.setLastname(rs.getString(3));
c.setEmail(rs.getString(4));
c.setFee(rs.getFloat(5));
list.add(c);
}
con.close();
}catch(Exception e){System.out.println(e);}
return list;
}
}
Comments
Leave a comment